Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

API

URLHTTP TypeDescription
/fileHandle POSTPost a list of Files (content-type= 'multipart/form-data').  For each File included in the POST, a FileHandle will be created and returned.  The ID of the returned FileHandles can be used to assign the file to a Synapse objects such as WikiPage attachments or FileEntity.
This method is deprecated.  Please use the Chunk File Upload.
/externalFileHandlePOSTPost an external File Handle.   Note: The body of the request is an ExternalFileHandle object, wrapping the URL to be stored.
/fileHandle/{handleId}GETGet the FileHandle for a given FileHandle ID.  Only the original creator of the FileHandle is authorized to get a FileHandle or assign a FileHandle to a Synapse Object such as WikiPage attachment or FileEntity.
/fileHandle/{handleId}DELETEDelete a FileHandle by its ID.  This will also trigger the delete of the corresponding file in S3 (when relevant) and any preview automatically generated for the FileHandle.

...

Chunked File Upload API

While it is possible to upload very larger files with a single HTTP request, it is not recommended to do so.  If anything were to go wrong the only option would be start over from the beginning.  The longer a file upload takes the less likely restarting will be acceptable to users.  To address this type of issue, Synapse provides 'chunked' file upload as the recommended method for upload all files.  This means the client-side software divides larger files into chunks and sends each chunk separately.  The server code will then reassemble all of the chunks into a single file once the upload is complete.  Any file that is less than or equal to 5 MB should be uploaded as a single chunk.  All larger files should be chunked into 5 MB chunks, each sent separately.  If any chunk fails, simply resend the failed chunk.   While this puts an extra burden on client-side developers the results are more robust and responsive code.  The following table shows the four web-service calls used for chunked file upload.  For these calls the request and response objects are not the same, so both will be shown:

largefiletokencontent-type= ''After all part of a large file have been posted, this call is used to complete the process and retrieve the resulting FileHandle of the large file
 Response (type)URLHTTP TypeRequest (type)Description
1ChunkedFileToken (application/json)/createChunkedFileUploadTokenPOSTCreateChunkedFileTokenRequest (application/json)Create a new large file tokenChunkedFileTokenA large file token is required to upload a large file.
/largefilepartPOST (content-type= 'multipart/form-data')Post a single part of a large file.  The large file token and the part number should be included include with the file POST.
/largefilecompletePOST(content-type= 'application/json')This token must be provided in all subsequent requests.
2URL (text/plain)/createChunkedFileUploadChunkURLPOSTChunkRequest (application/json)Create a pre-signed URL that will be used to PUT a single file chunk. This step is repeated for each chunk.
3ChunkResult (application/json)/addChunkToFilePOSTChunkRequest (application/json)After a chunk is PUT to a pre-signed URL, it must be added to file.  You will need the returned ChunkResult to complete the upload. This step is repeated for each chunk.
4S3FileHandle (application/json)/completeChunkFileUploadPOSTCompleteChunkedFileRequest (application/json)After all chunks have been added, complete the upload with this call.  The resulting S3FileHandle can be used for any object that accepts FileHandles.