GET Files

/v1/files/<external_key>

Method: GET
Description: Returns the specified file or the list of files and folders depending on <external_key>.

  • If <external_key> is empty, the list of files and folders of the root folder is returned.
  • If <external_key> belongs to a folder, the list of files and folders from the specified folder is returned.
  • If <external_key> belongs to a file, the file is returned.

Result:
1) If <external_key> is empty or belongs to a folder, the list of files and folders is returned with the following properties:

Name – file or folder name
ExternalKey – file or folder key
ContentType – the MIME content-type of the stored file or “caspio/folder” for folder
Size – file size in bytes (note: only available for files)
DateCreated – file or folder creation date and time
LastModified – file or folder last modification date and time

2) If <external_key> belongs to a file, the file is returned, with its properties in headers.

Example 1

Returns the list of files and folders with their ExternalKeys from the root folder:
Method:  GET
URL:     /v1/files/

Example 2

Returns the list of files and folders with their ExternalKeys from the specified folder identified by the folder ExternalKey: “B54599D4-25FF-4C13-97FA-DAC25D605212”:
Method:  GET
URL:     /v1/files/B54599D4-25FF-4C13-97FA-DAC25D605212

RESPONSE for EXAMPLE 1 and 2

JSON:

"Result": [{
             "ContentType": "caspio/folder",
             "Name": "Marketing Folder",
             "ExternalKey": "75143333-6f43-4dc5-be65-db4425e45a74",
             "DateCreated": "2018-10-11T10:47:23.85"
            },
            {
             "Size": 15012,
             "LastModified": "2018-10-10T14:09:02.74",
             "ContentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
             "Name": "Mutual NDA.docx",
             "ExternalKey": "ab7f9ce0-c888-48b2-912a-9f7e4ce5333a",
             "DateCreated": "2018-10-04T13:55:28.817"
            },
            {
             "Size": 2133,
             "LastModified": null,
             "ContentType": "image/jpeg",
             "Name": "banner.jpg",
             "ExternalKey": "59fc2fb3-5a2b-4f0d-bf70-cd1d5f3c17ad",
             "DateCreated": "2018-08-04T10:06:53.503"
            }]

XML:

<?xml version="1.0" encoding="utf-16"?>
<Caspio xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <Result>
  <Folder>
   <Name>Marketing Folder</Name>
   <ExternalKey>75143333-6f43-4dc5-be65-db4425e45a74a</ExternalKey>
   <DateCreated>2018-10-11T10:47:23.85</DateCreated>
   <ContentType>caspio/folder<ContentType/>
  </Folder>
  <File>
   <Name>Mutual NDA.docx</Name>
   <ExternalKey>ab7f9ce0-c888-48b2-912a-9f7e4ce5333a</ExternalKey>
   <DateCreated>2018-10-04T13:55:28.817</DateCreated>
   <Size>15012</Size>
   <DateModified>2018-10-10T14:09:02.74</DateModified>
   <ContentType>application/vnd.openxmlformats-officedocument.wordprocessingml.document</ContentType>
  </File>
  <File>
   <Name>banner.jpg</Name>
   <ExternalKey>59fc2fb3-5a2b-4f0d-bf70-cd1d5f3c17ad</ExternalKey>
   <DateCreated>2018-08-04T10:06:53.503</DateCreated>
   <Size>2133</Size>
   <DateModified xsi:nil="true" />
   <ContentType>image/jpeg</ContentType>
  </File>
 </Result>
</Caspio>

Example 3

Retrieve file “Mutual NDA.txt” data identified by ExternalKey: “75143333-6f43-4dc5-be65-db4425e45a74”:
Method:  GET
URL:     /v1/files/75143333-6f43-4dc5-be65-db4425e45a74

RESPONSE for EXAMPLE 3

HTTP/1.1 200 OK
Content-Length: 447
Content-Type: text/plain
Content-Disposition: attachment; filename=Mutual NDA.txt
Filename: Lorem_ipsum.txt

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

POST Files

/v1/files/<external_key>

Method: POST
Description: Uploads one or more files into the Files area of the Caspio Bridge account. POST cannot overwrite existing files. Use the PUT method if you want to replace an existing file.

  • If <external_key> is empty, the root folder is used as the destination.
  • • If a file with the same name as the uploaded file exists “409 Conflict” is returned.

For a single file upload, the following parts of HTTP Message are required:

  • HTTP Headers:

Content-Type: – a MIME content-type
Content-Disposition: attachment; filename=<filename> – name under which the file will be stored in Caspio Bridge database

  • Body – file data (note: a MIME multi-part content is not allowed)

For multiple files upload, the following listed parts of HTTP Message are required:

  • HTTP Headers:

Content-Type: multipart/form-data

  • Body – a MIME multi-part content. Each part of the multi-part content must contain:

Content-Type: – a MIME content-type
Content-Disposition: attachment; filename=<filename> – name under which the file will be stored in Caspio Bridge database

Example 4

Upload file “Mutual NDA.txt” to the root folder:
Method:  POST
URL:     /v1/files
HTTP request:

POST <Resource Endpoint>/files HTTP/1.1
Host: yoursite.caspio.com
Content-Type: text/plain
Content-Length: 447
Content-Disposition: attachment; filename="Mutual NDA.txt"

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Example 5

Upload file “Mutual NDA.txt” to the folder identified by ExternalKey: “B54599D4-25FF-4C13-97FA-DAC25D605212”:
Method:  POST
URL:     /v1/files/B54599D4-25FF-4C13-97FA-DAC25D605212

HTTP request will be the same as in Example 4 with one change: the first line needs to include the ExternalKey of the folder as shown below:

POST <Resource Endpoint>/v1/files/B54599D4-25FF-4C13-97FA-DAC25D605212 HTTP/1.1

RESPONSE for EXAMPLE 4 and 5

Provided that the file name is not a duplicate in the destination folder the following is returned:

HTTP/1.1 201 Created
Content-Length: 106
Content-Type: application/json
"Result": [{
            "Name": "Mutual NDA.txt",
            "ExternalKey": "75143333-6f43-4dc5-be65-db4425e45a74"
          }]

If the destination folder contains a file with the same name as the uploaded file the upload will fail and the following response is returned:

HTTP/1.1 209 Conflict
Content-Length: 200
Content-Type: application/json
"Result": [{
            "Code":"DuplicateFileOrFolderName",
            "Message":"Action failed. Duplicate File or folder name.",
            "Resource":"<Resource Endpoint>/v1/files",
            "RequestId":"ABCBC7F2-A54A-4E6C-A1C4-38AED280B26E"
          }]

Example 6

Multi-part upload files “Mutual NDA.txt” and “Product Description.txt” to the root folder:
Method:  POST
URL:     /v1/files
HTTP request:

POST <Resource Endpoint>/files HTTP/1.1
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
Host: yoursite.caspio.com
Content-Length: 1258

---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="Mutual NDA.txt"
Content-Type: text/plain

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="Product Description.txt"
Content-Type: text/plain

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
---------------------------acebdf13572468--

RESPONSE for EXAMPLE 6

HTTP/1.1 201 Created
Content-Length: 180
Content-Type: application/json
"Result": [
            {"Name":"Mutual NDA.txt",
            "ExternalKey":"a2bd39c5-2495-4639-8ad8-9f6e3e0ff577"},
           {"Name":" Product Description.txt",
            "ExternalKey":"a72c7467-6ff0-4668-bdbe-d69c425deeb4"}
          ]

PUT Files

/v1/files/<external_key;>
Method: PUT
Description: Uploads one or more files into the Files area of the Caspio Bridge account. PUT works similar to POST, except that if the destination folder contains a duplicate file name, it is replaced by the new file.

  • If <external_key> is empty it uploads to the root folder.
  • If a file with the same name as the uploaded file exists it will overwrite it and return “200 OK”.

Please see POST Files for all details.