Reputation: 3750
I am trying to upload an HTML file to Google Cloud Storage and save a URL with it as metadata. The below code is successfully uploading the HTML, but doesn't seem to be setting the metadata, as when I select "Edit metadata" from the drop down for the file in the Cloud Storage web UI, the URL key is not shown, only "Content-Type".
await file.save(html, { contentType: "text/html", resumable: false, metadata: { url: "example.com" } });
Upvotes: 0
Views: 1341
Reputation: 3750
I worked out that when you want to set custom metadata as well as contentType etc, you need to wrap the whole thing as a meta data key value like this:
await file.save(html, {
metadata: {
contentType: "text/html",
resumable: false,
metadata: { url: "example.com" },
},
});
Upvotes: 5