You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Storage}from'@google-cloud/storage';constgcs=newStorage({projectId: // ...,credentials: // ...});constbucket=gcs.bucket('my-bucket');asyncfunctionrun(){constpath='some/file';constcontent1='some-content';constfile=bucket.file(path);awaitfile.save(Buffer.from(content1),{resumable: false,validation: false});const[readContent1]=awaitfile.download({validation: false,});readContent1.toString('utf8')===content1;// trueconstcontent2='some-other-content';awaitfile.save(Buffer.from(content2),{resumable: false,validation: false});const[readContent2]=awaitfile.download({// This is necessary to check the content of the second download, otherwise it throws with:// "The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again."validation: false});readContent2.toString('utf8')===content2;// false// readContent2 === 'some-contentsome-o'}run();
[REQUIRED] Steps to reproduce
Simply run the above example with the storage emulator properly configured.
[REQUIRED] Expected behavior
The content of the newly uploaded file should replace the existing one, so readContent2 === 'some-other-content' in the test case.
[REQUIRED] Actual behavior
The new content is appended to the previously uploaded one, instead of completely replacing it, which makes the storage emulator useless if a file is modified at least once.
[REQUIRED] Environment info
firebase-tools: 9.11.0
Platform: macOS, Ubuntu
[REQUIRED] Test case
[REQUIRED] Steps to reproduce
Simply run the above example with the storage emulator properly configured.
[REQUIRED] Expected behavior
The content of the newly uploaded file should replace the existing one, so
readContent2 === 'some-other-content'
in the test case.[REQUIRED] Actual behavior
The new content is appended to the previously uploaded one, instead of completely replacing it, which makes the storage emulator useless if a file is modified at least once.
It seems that the gcloud storage layer currently calls
oneShotUpload()
that appends content to the existing one, instead of replacing it in this case.The text was updated successfully, but these errors were encountered: