Skip to content

18504 - Add TUS resumable upload entity - #19

Open
ghultink wants to merge 1 commit into
masterfrom
feature/18504-tus-upload
Open

18504 - Add TUS resumable upload entity#19
ghultink wants to merge 1 commit into
masterfrom
feature/18504-tus-upload

Conversation

@ghultink

Copy link
Copy Markdown
Contributor

Summary

Adds $sdk->tus entity for TUS protocol resumable uploads via /sapi/tus.

Methods

Method HTTP Endpoint Description
initUpload() POST /sapi/tus Create upload, returns uploadId + presigned S3 URLs
getStatus() HEAD /sapi/tus/{id} Get offset + remaining presigned URLs (resume)
complete() POST /sapi/tus/{id}/complete Finalize S3 multipart upload
abort() DELETE /sapi/tus/{id} Terminate upload, clean up S3
signPart() GET /sapi/tus/{id}/sign/{part} Get fresh presigned URL for a part

Usage

$sdk = Sdk::withRPCTokenAuthentication($pub, $id, $secret);

// 1. Init upload
$response = $sdk->tus->initUpload('video.mp4', 104857600);
$body = $response->getDecodedBody();
// $body contains uploadId, presignedUrls, partSize

// 2. Client uploads parts directly to S3 via presigned URLs

// 3. Complete
$sdk->tus->complete($body['uploadId'], $completedParts);

Design

  • File data never passes through PHP — only TUS coordination via SAPI
  • Same mechanism as OVP6 and Uppy companion use
  • Follows SDK entity pattern with async-first + AutoAsyncToSyncCaller

New Tus entity (->tus) for TUS protocol resumable uploads via /sapi/tus.

Methods:
- initUpload(filename, filesize, clipId?, metadata?) → POST /sapi/tus
  Returns uploadId + presigned S3 URLs for direct chunk uploads
- getStatus(uploadId) → HEAD /sapi/tus/{id}
  Returns current offset + remaining presigned URLs (for resume)
- complete(uploadId, parts) → POST /sapi/tus/{id}/complete
  Finalizes the S3 multipart upload
- abort(uploadId) → DELETE /sapi/tus/{id}
  Terminates upload, cleans up S3 state
- signPart(uploadId, partNumber) → GET /sapi/tus/{id}/sign/{part}
  Gets a fresh presigned URL for a specific part (re-upload/expired)

All methods follow SDK pattern: async-first with AutoAsyncToSyncCaller.
File data never passes through PHP — only coordination via SAPI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant