PUT/projects/api/v1/pendingfiles/presignedurl.json

File Upload (Preferred)

File uploading with the API is a 3 step process:


  1. Generate the link: Send a GET request to the presigned URL with the file details:
  • fileName
  • fileSize

This will return a ref ID and a URL for uploading.

Endpoint: http://YOURSITE/projects/api/v1/pendingfiles/presignedurl.json?fileName=test.txt&fileSize=1024

Response:

{
  "ref": "tf_...",
  "url": "https://tw-bucket.s3.amazonaws.com/tf_...?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=...&X-Amz-Date=20190413T083843Z&X-Amz-Expires=600&X-Amz-Security-Token=...&X-Amz-SignedHeaders=content-length%3Bhost%3Bx-amz-acl&X-Amz-Signature=..."
}
  1. Upload the file: Send a PUT request to the link above, with the 'file' in the body of the request. Along with this, you need the following hearders:
  • X-Amz-Acl: public-read
  • Content-Length: file-size
  • Host: host-from-the-generate-link

Coding Example

curl -v -i -X PUT --data-binary "@test.txt" --header "X-Amz-Acl: public-read" --header "Host: tw-bucket.s3.amazonaws.com" --header "Content-Length: 1024" https://tw-bucket.s3.amazonaws.com/...

If successful you should get a 200 response.

3.Finalize the file upload: You can now use the ref ID from the first GET request to attach it to an object eg. task.

To attach to a task: PUT: /tasks/ID.json

{
  "todo-item": {
    "pendingFileAttachments": "tf_..."
  }
}