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

186
Visualizações
Firebase storage API - upload file with metada

I am using the rest api to upload files to firebase storage as described in the following answer https://stackoverflow.com/a/65462416/8634683.

And I would like to set the cache-control metadata but can't figure it out.

I found the next firebase doc - https://firebase.google.com/docs/storage/web/file-metadata but didn't saw any information about the rest API.

=== Update ====

So I did a little bit of reverse engineering, , and I found that when I am using the JS-SDK, the library add a prefix to the file, Any one know what is the meaning of the first long number?

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So I found the answer:

Send the blob file with a prefix and suffix as follow:

let prefix = `
--23483860318350978727016216849495
Content-Type: application/json; charset=utf-8
Content-Disposition: form-data; name="metadata"

{"name":"${filePath}", "cacheControl":"max-age=7200","contentType":"${fileType}"}
                
--23483860318350978727016216849495
Content-Type: ${fileType}`

let suffix = '\n--23483860318350978727016216849495--'

let blobWithMetadata = new Blob([prefix, blob, suffix])

and add the following headers:

headers = { 
  'x-goog-upload-protocol': 'multipart',
  'content-type': 'multipart/related; boundary=23483860318350978727016216849495'
}
about 4 years ago · Juan Pablo Isaza 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