MCPcopy Create free account
hub / github.com/fontsource/fontsource / completeMultipartUpload

Function completeMultipartUpload

api/download/src/bucket.ts:180–210  ·  view source on GitHub ↗
(
	bucketPath: string,
	uploadId: string,
	parts: R2UploadedPart[],
)

Source from the content-addressed store, hash-verified

178};
179
180const completeMultipartUpload = async (
181 bucketPath: string,
182 uploadId: string,
183 parts: R2UploadedPart[],
184) => {
185 const resp = await fetch(
186 `https://upload.fontsource.org/multipart/${bucketPath}?action=mpu-complete`,
187 {
188 method: 'POST',
189 headers: {
190 Authorization: `Bearer ${
191 // biome-ignore lint/style/noNonNullAssertion: <explanation>
192 process.env.UPLOAD_KEY!
193 }`,
194 'Content-Type': 'application/json',
195 },
196 body: JSON.stringify({
197 uploadId,
198 parts,
199 }),
200 },
201 );
202
203 if (!resp.ok) {
204 const error = await resp.text();
205 const msg = `Unable to complete multipart upload. ${error}`;
206
207 await abortMultiPartUpload(bucketPath, uploadId, msg);
208 handleBucketError(resp, msg);
209 }
210};
211
212export const putBucket = async (
213 bucketPath: string,

Callers 1

putBucketFunction · 0.85

Calls 4

abortMultiPartUploadFunction · 0.85
handleBucketErrorFunction · 0.85
textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected