leaysgur/cfw-bindings-wrangler-bridge

R2 Multipart support

Closed this issue · 0 comments

// Creates a multipart upload.
// Returns Promise which resolves to an R2MultipartUpload object representing the newly created multipart upload.
// Once the multipart upload has been created, the multipart upload can be immediately interacted with globally, either through the Workers API, or through the S3 API.
R2Bucket.createMultipartUpload(
  key: string,
  options?: R2MultipartOptions
): Promise<R2MultipartUpload>;

// Returns an object representing a multipart upload with the given key and uploadId.
// The resumeMultipartUpload operation does not perform any checks to ensure the validity of the uploadId, nor does it verify the existence of a corresponding active multipart upload.
// This is done to minimize latency before being able to call subsequent operations on the R2MultipartUpload object.
R2Bucket.resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;

interface R2MultipartOptions {
  httpMetadata?: R2HTTPMetadata | Headers;
  customMetadata?: Record<string, string>;
}

interface R2MultipartUpload {
  readonly key: string;
  readonly uploadId: string;
  uploadPart(
    partNumber: number,
    value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
  ): Promise<R2UploadedPart>;
  abort(): Promise<void>;
  complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
}

interface R2UploadedPart {
  partNumber: number;
  etag: string;
}