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

199
Visualizações
What Format should FormData have?

so I want to upload the test JSON to arweave. The appending of transaction and env works fine, but when I try to append bufferTest I get this error

Unhandled Rejection (TypeError): Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'.

I tried doing: data.append('file[]', new Blob(bufferTest), 'metadata.json');, but then it just uploads the Buffer values in UTF8 like this: 1.2334116101115117e+39. I literally just copied this from Metaplex candy-machine-v2. They also just append the Buffer. I don't know if this has something to do with React or me just being stupid.

const test = { "test": "test" };
const bufferTest: any = Buffer.from(JSON.stringify(test)); //metadata as buffer

export default function Test(props:any){

    //...
    const data = new FormData();
    data.append('transaction', txID!); // Transaction ID
    data.append('env', env);  // env = devnet
    data.append('file[]', bufferTest, 'metadata.json');

    const result = await upload(data);
    //...

}
async function upload(data: FormData) {
    return await (
        await fetch(ARWEAVE_UPLOAD_ENDPOINT, {
            method: 'POST',
            // @ts-ignore
            body: data,
        })
    ).json();
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you need to put a for loop on all files selected inside the input file like the bellow :

var len = document.getElementById('XXXX').files.length;
for (var i = 0; i < len ; i++) {
    fd.append("file[]", document.getElementById('XXXX').files[i]);
}

let me know if it's working

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