Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Orion/Server API/Transfer API

< Orion‎ | Server API
Revision as of 12:20, 11 March 2011 by Mamacdon.ca.ibm.com (Talk | contribs) (add Server API category)

Under Construction: This API is not yet implemented

The transfer API is used for batch import and export of directory trees to/from an Orion workspace.

Import

Starting a file upload

Overview
A resumable chunked upload is initiated via a POST request. The request URL indicates where the file should be located once the upload is complete. The request must indicate the total size of the file the server should expect.
HTTP Method
POST
Example Request
POST /xfer/MyProj/SomeFolder
Orion-Version: 1.0
Slug: MyTitle
X-Xfer-Content-Length: 901024

  
Example Response
HTTP/1.1 200 OK
Location: /xfer/import/23A43


Detailed Explanation
The Location header in the response indicates the URL where chunks of the file should be uploaded. Once the server has received all chunks, the import into the workspace is completed. An upload that is not completed in a timely fashion from the initial POST is discarded by the server.


Uploading a file

After initiating the transfer, uploads are performed as many times as required using PUT actions:


Overview
Uploads a chunk of a file to the server.
HTTP Method
PUT
Example Request
PUT /xfer/import/23A43
Orion-Version: 1.0
Content-Length: 32768
Content-Type: application/zip
Content-Range: bytes 0-32767/901024
X-Xfer-Options: raw

  
Example Response
HTTP/1.1 308 Resume Incomplete
Range: bytes 0-30000


Detailed Explanation
A response of 308 indicates that the server has not yet received all required bytes, and the Range response header indicates the bytes known to the server so far. When the server has received all bytes, a 201 Created response is returned, with a Location header specifying the location of the newly added file or directory. The X-Xfer-Options header specifies what the server should do with the file when the upload completes. By default the server assumes the file is an archive and will attempt to extract it into the destination location. When importing a single file, the "raw" option can be used to indicate that the server should simply place the uploaded file at the specified location.


Importing a zip

The chunked file upload service can also be used to import an archive file that will be expanded upon completion of import. This allows a large number of files to be imported into a project at once.


Overview
An upload is initiated via a POST request. The request URL indicates where the file should be located once the upload is complete. The request must indicate the total size of the file the server should expect.
HTTP Method
POST
Example Request
POST /xfer/MyProj/SomeFolder
Orion-Version: 1.0
X-Xfer-Content-Length: 901024

  
Example Response
HTTP/1.1 200 OK
Location: /xfer/import/23A43


Detailed Explanation
The Location header in the response indicates the URL where chunks of the file should be uploaded. Once the server has received all chunks, the file is unzipped into the destination location on the server. An upload that is not completed in a timely fashion from the initial POST is discarded by the server.


Importing a file via a single POST call

Overview
Although the resumable chunk-based upload approach is recommended for large files, you can also import a file with a single POST call. Simply omit the X-Xfer-Content-Length header, and include the file to be uploaded as the request body.
HTTP Method
POST
Example Request
POST /xfer/MyProj/SomeFolder
Orion-Version: 1.0
Content-Length: 901024
Content-Type: application/zip

This is the file contents  
Example Response
HTTP/1.1 201 OK
Location: /file/MyProj/SomeFolder


Detailed Explanation
If the POST method body contains the entire content, then 201 response is returned and the import is complete. If the entire content is not received, then a 308 response is returned along with the range received by the server. The client can then resume or complete the upload via a subsequent PUT operation with appropriate range. The file is only imported into the workspace once the entire content is received.



Export

  • GET request /xfer/export/pathToExport.zip
  • Request Content-Type indicates archive format (default=application/zip)

Back to the top