Skip to content
Developerhome
Sage Distribution and Manufacturing Operations

Create the attachment record

  Less than to read

Create a record in the attachment node.

This record stores all the attachments associated with a document.

To create a record, you need to create an entry with the following information:

  • File name
  • Mime type
  • Size of the file
  • The status that is created

This GraphQL query uses a list of parameters that must be filled in. This query is done when a PUT on the URL is returned by the authentication to access the right tenant with a token.

The returned information is:

  • An internal ID
  • A key
  • An upload URL
  • Additional information such as the name of the file or the mime type

The following table displays an example and the result of creating a record in the attachment node. Some of the fields displayed are not mandatory and others have been omitted.

mutation (
        $FileName:String!, 
        $MimeType:String!, 
        $ContentLength:IntOrString, 
        $LastModified:Datetime
    )
    { 
        xtremUpload { 
            attachment { 
                create (data: { 
                    filename: $FileName, 
                    mimeType: $MimeType, 
                    lastModified: $LastModified, 
                    contentLength: $ContentLength, 
                    status: "created" 
                }) { 
                    _id 
                    uploadUrl 
                    key 
                    filename 
                    mimeType 
                } 
            } 
        } 
    }
{ 
    "data": { 
        "xtremUpload": { 
            "attachment": { 
                "create": { 
                    "_id": "1915", 
                    "uploadUrl": "…", 
                    "key": "noz4hMRHl-f5dnDQcMIQS", 
                    "filename": "myfile.jpg", 
                    "mimeType": "image/jpeg" 
                } 
            } 
        } 
    }, 
    "extensions": { 
        "diagnoses": [] 
    } 
}