Skip to content

Commit

Permalink
Fix missing upload status heade in resumable upload finalise response (
Browse files Browse the repository at this point in the history
  • Loading branch information
tohhsinpei committed Apr 6, 2022
1 parent 19d3e24 commit 0adffd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/storage-emulator-integration/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2127,14 +2127,17 @@ describe("Storage emulator", () => {
})
.expect(200);

await supertest(STORAGE_EMULATOR_HOST)
const uploadStatus = await supertest(STORAGE_EMULATOR_HOST)
.put(uploadURL.pathname + uploadURL.search)
.set({
// No Authorization required in finalize
"X-Goog-Upload-Protocol": "resumable",
"X-Goog-Upload-Command": "upload, finalize",
})
.expect(200);
.expect(200)
.then((res) => res.header["x-goog-upload-status"]);

expect(uploadStatus).to.equal("final");

await supertest(STORAGE_EMULATOR_HOST)
.get(`/v0/b/${storageBucket}/o/test_upload.jpg`)
Expand Down
1 change: 1 addition & 0 deletions src/emulator/storage/apis/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export function createFirebaseEndpoints(emulator: StorageEmulator): Router {
throw err;
}

res.header("x-goog-upload-status", "final");
storedMetadata.addDownloadToken(/* shouldTrigger = */ false);
return res.status(200).json(new OutgoingFirebaseMetadata(storedMetadata));
}
Expand Down

0 comments on commit 0adffd8

Please sign in to comment.