Closed vkclogituit closed 8 months ago
Hi @vkclogituit I just tried the snippet you provided and I did not see any errors. Are you sure the object you are attempting to setMetadata
on exists? Have you verified with a .exists()
call to check?
exists() returns true but still this code fails and getting not found error on setting the metadata.
Looking at the above code file.exists
needs to either be provided a callback or await
ed for the promise form. The documentation is here.
I encountered an odd situation.
I uploaded video files ( mp4 ) to google bucket using preSigned Url and I have mentioned the same content type as video/mp4.
I can see the files on the bucket but those are not playing and showing the message as too large to view.
For those uploaded through preSigned url I could not able to set the metadata as file.exists returning false.
Would it be possible to see the code / an example of how you are uploading using a signed url?
Here is my upload code
And I can see the upload going well from network logs
There were two issues, due to which I could not able to see the video playing and also not able to set the metadata. reason 1: treating folders also as bucket. instead of getting the bucket object by simply mention the bucket name, I was using the full path as bucket name ( except filename ) . Due to this file able to get placed correctly in right path but while setting the setMetada it was throwing the error.
Reason 2: from angular, I was uploading video file and setting the type as file instead of 'video'- due to that I could not able to play it back when I render the object .
So it is my mistake,
Thank you @ddelgrosso1 for guiding on this.
Following block of code is given in the samples of this project.
And, I have create a object in the google cloud bucket and then I am trying to set the custom metadata for the same.
But this code block is throwing same error. ( Not Found )
const options = { ifMetagenerationMatch: 0, };
storage.bucket(bucketName) .file(filename) .setMetadata(
{ contentType: 'video/mp4', metadata: { description: 'file description...', modified: '1900-01-01', }, }, options
).then((data) => { console.log('COMPLETED) }).catch((error) => { console.log(error) });
Environment Details:
@google-cloud/storage
version: 7.5.0Steps to reproduce