Skip to content

Upload a file

POST /api/uploadFiles

Upload a file to Formbird

Arguments
  • your apiKey, for example: bf5b0500-9332-11e6-9c03-853f647fe4a4

  • a document containing the file and associated information, for example:

json { "documentId": "d1fd5a30-de84-11e6-a89a-f9fe3a98b30b", "uploadedFile": "data:text/plain;base64,dGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==", "fileName": "sample.txt" }

value required description
documentId true An existing document the file will be associated with upon upload. Note that all files should always be associated with a document
uploadedFile true The file content in dataURI* format
fileName true The file's modified or original filename
fileNo false You may set the file's custom UUID so it can later be retrieved using the same UUID at: /api/getFile/

Tip: For nodejs applications, you may use external modules such as datauri to convert file contents into dataURI as shown in the following example:

var DataURI = require('datauri').promise;
DataURI('test/test.txt')
.then(function (content) {
    //content is the file in dataURI format
})
.catch(function (err) {
    console.log(err.message)
});
Example Request
curl http://localhost:3000/api/uploadFiles \
 -H "Content-Type: application/json;charset=UTF-8" \
 -H "apiKey: bf5b0500-9332-11e6-9c03-853f647fe4a4" \
 -d "{\"documentId\": \"d1fd5a30-de84-11e6-a89a-f9fe3a98b30b\", \"uploadedFile\": \"data:text/plain;base64,dGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==\", \"fileName\": \"sample.txt\"}"

The above example request supplies an encoded text file (with the content: “this is a test file content.”); its fileName; and a documentId to associate with the uploaded file.

Example Response
{"fileNo": "fc30dea0-ffc9-gggg-a3c5-f1d9c5618eaf"}

The response contains a json object containing the file's UUID which you can use to retrieve the file using: /api/getFile/