POST/users/{userId}/drive/files

Creates a URL for uploading a file to my drive. Users can use this URL to upload files.

Note

  • For how to download content using the API, see Upload or Download Files.

Authorization

oauth2

OAuth 2.0 authentication.
For more information, see Authentication and Authorization.

Scope

file

HTTP Request

POSThttps://www.worksapis.com/v1.0/users/{userId}/drive/files

Path Parameters

ParameterTypeDescription
userId string 

User ID

  • Mail
  • Resource ID
  • External key in "externalKey:{externalKey}" format
  • me

required
example : me 

Header Parameters

HeadertypeDescription
Authorization string 

Bearer {token}


required 
Content-Type string 

application/json


required
example : application/json 

Request Body

PropertyTypeDescription
fileName string 

File name


required
minLength : 1
maxLength : 200 
modifiedTime string 

File update date


minLength : 1
format : date-time 
fileSize integer 

File size


required
maximum : 10737418240
format : int64 
overwrite boolean 

Indicates whether to overwrite the file.


default : false 
suffixOnDuplicate boolean 

Indicates whether to use automatic numbering
If it is true, a number is automatically added to a file or folder name when a file or folder with the same name already exists in the destination folder.


default : false 
resume boolean 

Indicates whether the upload is resumable.
To resume the upload from where it left off, set resume:true for the same upload request.


default : false 

Request Example

example

1{2  "fileName": "works.txt",3  "modifiedTime": "2019-08-24T14:15:22Z",4  "fileSize": 100,5  "overwrite": false,6  "resume": false,7  "suffixOnDuplicate": false8}

example(resume)

1{2  "fileName": "works.txt",3  "modifiedTime": "2019-08-24T14:15:22Z",4  "fileSize": 100,5  "overwrite": false,6  "resume": true,7  "suffixOnDuplicate": false8}

Response

HTTP 200

OK

PropertyTypeDescription
uploadUrl string 

File upload URL


required 
offset integer 

It is used to resume the previously interrupted upload if resume:true is set.
Note that it is set to 0 if there is no upload to resume.
To resume the upload, you need to pass the offset value in the Content-Range header.

Example) If fileSize is 1000 and offset is 100
Content-Range=100-999/1000


format : int64 

Response Example

example

1{2  "uploadUrl": "https://apis-storage.worksmobile.com/k1/drive/r/24101/160521/160521/100001500064253/3472589353794602761?param=ewogICJwYXJlbnRLZXkiIDogInJvb3QiLAogICJmaWxlTmFtZSIgOiAi7ZWc6riALnR4dCIsCiAgImZpbGVTaXplIiA6IDMsCiAgIm1vZGlmaWVkVGltZSIgOiAiMjAxOS0wOC0yNFQxNDoxNToyMloiLAogICJhZGRvbktleSIgOiBudWxsCn0&writeMode=none&auth=OPEN",3  "offset": 04}

example(resume)

1{2  "uploadUrl": "https://apis-storage.worksmobile.com/k1/drive/r/24101/160521/160521/100001500064253/3472589353794602761?param=ewogICJwYXJlbnRLZXkiIDogInJvb3QiLAogICJmaWxlTmFtZSIgOiAi7ZWc6riALnR4dCIsCiAgImZpbGVTaXplIiA6IDMsCiAgIm1vZGlmaWVkVGltZSIgOiAiMjAxOS0wOC0yNFQxNDoxNToyMloiLAogICJhZGRvbktleSIgOiBudWxsCn0&writeMode=resume&rangeStartOffset=100&auth=OPEN",3  "offset": 1004}