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

179
Visualizações
Could not get the data in URL.createObjectURL

I am just curious about how to get the data wrapped in URL.createObjectURL.

So I write the following code.

function typedArrayToURL(typedArray, mimeType) {
  return URL.createObjectURL(new Blob([typedArray.buffer], {type: mimeType}))
}
const bytes = Uint8Array.from("https://www.baidu.com/")
// const url = typedArrayToURL(bytes, 'text/html');
const url = typedArrayToURL(bytes, 'text/plain; charset=utf-8');

let blob = await (await fetch(url)).blob();
console.info(new Uint8Array(blob))

let ab = await (await fetch(url)).arrayBuffer();
console.info(new Uint8Array(ab))

The size of blob or ab 22 which is eqauls to the length of "https://www.baidu.com/", but the data in it is all zero.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

An intArray expects integers. So you will have to provide the data in the correct format.

So something like

const bytes = Uint8Array.from("https://www.baidu.com/".split('').map(v=>v.charCodeAt(0)));

or

const encoder = new TextEncoder();
const bytes = Uint8Array.from(encoder.encode("https://www.baidu.com/"))
about 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