- API
- Chunked upload
GET
https://send.now/api/upload/chunk?key=1ltghrilhllgrx2b2
| Parameters |
Description |
Example |
Format |
Required |
| key |
API-Key |
1ltghrilhllgrx2b2 |
String |
yes |
Step 1 - ask for an upload address
{
"msg": "OK",
"status": 200,
"chunk_url": "https://u7134.send.now/cgi-bin/put_chunk.cgi?u=api",
"api_url": "https://u7134.send.now/cgi-bin/api.cgi?u=api",
"sess_id": "ynfejiddf0grvip0",
"upload_token": "1791160000.3fa9c1d3e5...",
"server_time": "2024-08-26 12:19:28"
}
Step 2 - send the file in chunks
| Header | Description | Example | Required |
| X-Upload-SID | An id you choose for this upload, the same on every request of it: 10 to 64 letters and digits. A random 16-digit number works everywhere | 4829174650318264 | yes |
| Content-Range | Where the chunk belongs in the file: bytes first-last/*, last byte included | bytes 0-5242879/* | yes |
| X-Upload-Token | upload_token of step 1, when it is not empty | 1791160000.3fa9... | when sent in step 1 |
The body is the bytes of the chunk. Send the chunks one after the other, in order, to the same chunk_url. The reply to a chunk is {"status":"OK"}.
Step 3 - finish the upload
POST api_url op=import_file
| Parameters | Description | Example | Required |
| op | import_file | import_file | yes |
| sid | The X-Upload-SID of the chunks | 4829174650318264 | yes |
| sess_id | sess_id of step 1: it says whose account gets the file | ynfejiddf0grvip0 | yes |
| fname | Name of the file | big.zip | yes |
| file_public | 1 = public, 0 = private. Send it, do not rely on the default | 0 | no |
| file_descr | Description | Backup | no |
| to_folder | Id of one of your folders (default: the top level) | 58 | no |
| link_pass | Password for the file | 123password | no |
Reply of step 3
{
"status": "OK",
"file_code": "byul9fp3ctyr",
"links": {
"download_link": "https://send.now/byul9fp3ctyr",
"short_link": "https://send.now/d/1pbZB",
"delete_link": "https://send.now/byul9fp3ctyr?killcode=77b1an60zs",
"forum_code": "[URL=https://send.now/byul9fp3ctyr]big.zip - 2.4 MB[/URL]",
"html_code": "<a href=\"https://send.now/byul9fp3ctyr\" target=_blank>big.zip - 2.4 MB</a>"
}
}
Reply of step 3 when the file is refused
{ "error": "file is too big" }
cURL example
# 1. address, session and token
curl 'https://send.now/api/upload/chunk?key=1ltghrilhllgrx2b2'
# 2. the chunks (here 5 MB each), same SID, Content-Range from the first to the last byte of the chunk
SID=4829174650318264
head -c 5242880 big.zip | curl -X PUT --data-binary @- \
-H "X-Upload-SID: $SID" -H "Content-Range: bytes 0-5242879/*" -H "X-Upload-Token: UPLOAD_TOKEN" 'CHUNK_URL'
# ...next chunk: bytes 5242880-10485759/*, and so on; the last one ends at size-1
# 3. finish
curl 'API_URL' -d op=import_file -d sid=$SID -d sess_id=SESS_ID -d fname=big.zip -d file_public=0
Notice
|
Use this for big files: a request that fails costs one chunk, not the whole file. A plain upload is in Upload server. |
|
Use the addresses of step 1 for all three steps: the chunks are kept on that file server until you finish. sess_id works for about an hour, upload_token for 12 hours. |
|
If a chunk fails, send the same chunk again with the same Content-Range: it replaces the earlier try. A chunk that starts after the end of what the server already has is refused (409). |
|
The size and storage limits of your account apply when the file is finished: a file that is too big, or does not fit in your storage, is refused in step 3 with {"error": ...}. |
|
The reply of step 3 is the file server's own: status is the word OK, errors come as error. |
Status code
| 200 |
Everything is OK. Request succeeded |
| 400 |
Bad request (e.g. wrong parameters) |
| 403 |
Permission denied |
| 404 |
File not found |
| 451 |
Unavailable
|