AttachmentStorage Object

Details on how to upload files to the R-Service attachment storage facility.

Various rich text fields in R-Service can hold attachments. They may contain inline image or video files, and some of them can have attachments listed externally, in which case in the R-Service UI these are displayed at the bottom of the text represented with a paperclip in front of each attachment.

Adding attachments and inline image or video files to rich text fields is a three-step process:

  1. Get access to the R-Service storage facility (this type provides the necessary details)
  2. Upload the files
  3. Use the keys obtained from the uploads as AttachmentInput.key arguments.

Query to retrieve the required data:

query {
  attachmentStorage {
  sizeLimit
  allowedExtensions
  uploadUri
  provider
  providerParameters
  }
}

An upload POST (to uploadUri) must use 'multipart/form-data' encoding according to RFC 2388. The upload must start with a field named Content-Type whose value is the correct content type of the file being uploaded. Subsequently all providerParameters must be supplied and finally a field named file containing the actual (binary) file content must be present.

When the provider is s3 the response to the upload will be XML, the Key element holds the value required to be used in AttachmentInput arguments. It will look something like:

<?xml version="1.0"?>
<PostResponse>
  <Location>https://R-Service.s3-accelerate.dualstack.amazonaws.com/attachments%2F5%2F2020%2F11%2F15%2F6%2F1605413834-431xxxc1be%%2Fhelloworld.txt</Location>
  <Bucket>R-Service</Bucket>
  <Key>attachments/5/2020/11/15/6/1605413834-431xxxcc1be/helloworld.txt</Key>
  <ETag>"9008d115b2d05a7ca6b495fd0cb998df"</ETag>
</PostResponse>

When the provider is local the response to the upload will be JSON, the key property holds the value required to be used in AttachmentInput arguments. It will look something like:

{
  "key": "attachments/5/.../helloworld.txt"
}

Fields

The fields in this section list which values can be retrieved when querying AttachmentStorage records.

allowedExtensions ([String!]!)

The permitted file extensions for uploads.

provider (String!)

Type of storage facility in use. One of:

  • local: On-premise environment storage.
  • s3: Cloud environment storage.
providerParameters (JSON!)

The mandatory fields and their values that should be added to an upload POST to the uploadUri.

sizeLimit (Int!)

The maximum size (in bytes) for uploads.

uploadUri (String!)

The URI that attachments should be uploaded to.