Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
How to change file's metadata in Google Cloud Storage with Reactjs

Im trying to update the metadata in Google Cloud Storage with Reactjs. I tried the exact code in this link How to change file's metadata in Google Cloud Storage with Node.js and it wont work on my end.

I also tried to import the ff:

import {Storage} from '@google-cloud/storage'

These are the error messages I am getting:

(1)

GET http://metadata.google.internal./computeMetadata/v1/instance net::ERR_NAME_NOT_RESOLVED

(2)

Uncaught (in promise) TypeError: Unexpected error determining execution environment:process.emitWarning is not a function

Here is my code

const storage = new Storage();

const file = storage
        .bucket(bucketName)
        .file(filename)

// Get the file's metadata 
const [metadata] = await file.getMetadata()

// update metadata    
file.setMetadata(metadata.metadata.example='updated')
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The @google-cloud/storage package is meant to be used on server side and not a web app. You can use a Cloud Function that'll update the metadata based on the data from client. For example:

const functions = require('@google-cloud/functions-framework');

functions.http('updateMetadata', async (req, res) => {
  const { metadata, filename } = req.body;

  const file = storage
        .bucket(bucketName)
        .file(filename)

  // update metadata

  res.json({ message: "File updated" })
});

If you are using Firebase Storage, then you can also Firebase Client SDK to update metadata from client side.

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!