Resume an interrupted API upload

Resume multipart API uploads from recorded part numbers, retry missing chunks safely, and complete only after every expected 10 MiB part has landed.

Last reviewed

Dosya selects multipart upload above 50 MiB. A client can request it for a smaller nonempty file with force_multipart: true. Multipart sessions use 10 MiB parts and resume by uploaded part number, not by a raw byte offset.

Four workflow panels show loading session status, uploading missing part numbers, accepting a repeated part safely, and completing after all expected parts.
The diagram covers loading session status, uploading missing part numbers, accepting a repeated part safely, and completing after all expected parts. Open full-size screenshot.

Before you start

  • Retain the session_id, source file, declared file_size, and any content hash until completion succeeds.
  • Resume as the same Dosya user in the same workspace with the original session and unchanged file. The credential may be an authorized replacement API key; it does not have to be the key that initialized the session.
  • An unstarted pending session becomes eligible for cleanup after 10 minutes, and multipart work can be retired after 24 hours without a landed part. The bucket’s seven-day multipart lifecycle is only a backstop, while complete or failed session rows can be pruned after seven days; status is the authority, not any promised expiry time.

Steps

  1. Call GET /api/upload/session_id/status. Read status, size_bytes, part_size, total_parts, bytes_uploaded, uploaded_parts, has_multipart, and file_id when completion has already produced one.
  2. If status already represents completion and file_id is present, verify that file instead of uploading more. For an active session, compute the missing integers from 1 through total_parts.
  3. Seek the local source to (partNumber - 1) × part_size and upload only each missing part to PUT /api/upload/session_id/part/partNumber. The final part may be shorter than 10 MiB.
  4. Treat a successful repeated part response with already_uploaded: true as confirmation, not duplication. Re-read status after transport failures because the server may have stored the part before the connection broke.
  5. Send POST /api/upload/session_id/complete only when status lists every expected part. If it says Only N of M parts uploaded. Upload remaining parts before completing., return to the missing-part calculation.
  6. Require the completion receipt’s file ID, then fetch its metadata and compare the final measured size or configured hash. Delete the local resume record only after that verification.
Dosya developer overview with API and SDK entry points for resume an interrupted api upload.
The developer overview supplies the API and SDK entry points referenced by “Resume an interrupted API upload”. Open full-size screenshot.

Expected result

Every expected part number appears in status, completion returns the stored file receipt, and a metadata read shows the finished object. Re-sending a recorded part does not add a second part.

Troubleshooting

Status is missing or expired. Start a new session only after confirming the old session can no longer be resumed.

The source file changed locally. Abort the resume. Part numbers from one byte sequence cannot safely finish another.

Completion reports missing parts. Trust uploaded_parts, upload only absent numbers, and call complete again. Do not translate bytes_uploaded into a byte-offset resume.

Was this helpful?

Loading helpfulness results…

Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.

Questions and replies

Ask about the steps in this guide. Questions are reviewed before publication.

Keep account details, credentials and private files out of public questions. Use private support for those.

Loading questions…

    Sign in to your Dosya account to ask a question.

    Check the outcome before you retry

    Use these shared checks when a task needs a second look.