Upload a file

POST /api/2.0/files/{folderid}/upload

Request

Uploads a file specified in the request to the selected folder by single file uploading or standart multipart/form-data method.

Note: Note: You can upload files in two different ways:

  1. Using single file upload. You should set the Content-Type and Content-Disposition headers to specify a file name and content type, and send the file to the request body.
  2. Using standart multipart/form-data method.

Authorization

An API key is a token that you provide when making API calls. Include the token in a cookie parameter called asc_auth_key.

Example: asc_auth_key=864FE52C-1C1C-469F-9308-51DAFEFE7436.

Headers

Acceptenum of string

Can be one of: application/json, text/json, text/plain.

Content-Typeenum of string

Can be one of: application/json, application/*+json, text/json.

Path

folderIdintegerformat: int32required

Folder ID

Body

Request parameters for uploading a file

filestringformat: binary

File

contentTypeobject
boundarystring
charSetstring
mediaTypestring
namestring
parametersarray of unknown
contentDispositionobject
dispositionTypestring
parametersarray of unknown
fileNamestring
creationDatestringformat: date-time
modificationDatestringformat: date-time
inlineboolean
readDatestringformat: date-time
sizeintegerformat: int64
filesarray of string

List of files when specified as multipart/form-data

createNewIfExistboolean

Specifies whether to create a new file if it already exists or not

storeOriginalFileFlagboolean

Specifies whether to upload documents in the original formats as well or not

keepConvertStatusboolean

Specifies whether to keep the file converting status or not

streamstringformat: binary

Request input stream

Examples

POST /api/2.0/files/%7Bfolderid%7D/upload HTTP/1.1
Accept: application/json
Content-Length: 536
Content-Type: application/json
Host: example.com

{
  "contentType": {
    "boundary": "some text",
    "charSet": "some text",
    "mediaType": "some text",
    "name": "Shanny Treutel"
  },
  "contentDisposition": {
    "dispositionType": "some text",
    "fileName": "some text",
    "creationDate": "2008-04-10T06:30:00.0000000+04:00",
    "modificationDate": "2008-04-10T06:30:00.0000000+04:00",
    "inline": true,
    "readDate": "2008-04-10T06:30:00.0000000+04:00",
    "size": 1234
  },
  "createNewIfExist": true,
  "storeOriginalFileFlag": true,
  "keepConvertStatus": true
}
curl --request POST \
  --url https://example.com/api/2.0/files/%7Bfolderid%7D/upload \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "contentType": {
    "boundary": "some text",
    "charSet": "some text",
    "mediaType": "some text",
    "name": "Shanny Treutel"
  },
  "contentDisposition": {
    "dispositionType": "some text",
    "fileName": "some text",
    "creationDate": "2008-04-10T06:30:00.0000000+04:00",
    "modificationDate": "2008-04-10T06:30:00.0000000+04:00",
    "inline": true,
    "readDate": "2008-04-10T06:30:00.0000000+04:00",
    "size": 1234
  },
  "createNewIfExist": true,
  "storeOriginalFileFlag": true,
  "keepConvertStatus": true
}'

Responses

200

Inserted file

401

Unauthorized

403

You don't have enough permission to create

404

Folder not found

Get Help

  • If you have any questions about ONLYOFFICE DocSpace, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).