Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda