Closed WakkoStar closed 3 years ago
I use react native and I don't know if my file object is correct.
export const createFormData = async (nom, gout_array, difficulty, image) => { const form = new formData();` //operations const CREATE_COCKTAIL = `mutation ($nom: String!, $gout_array: [Int!]!, $difficulty: String!, $file: Upload) { createCocktail (nom: $nom, gout_array: $gout_array, difficulty: $difficulty, file: $file) }`; const variables = { nom, gout_array, difficulty, file: null, }; const operations = JSON.stringify({query: CREATE_COCKTAIL, variables}); form.append('operations', operations); const body = new formData(); body.append('operations', operations); body.append('map', '{ "0": ["variables.file"] }'); const file = new File([b64toBlob(image.base64, image.type)], image.fileName, { type: image.type, }); body.append('0', file, image.fileName); return body; };
I've been stuck for 2 days.... Thank you !
I found my problem !
const file = {uri: image.uri, name: image.fileName, type: image.type}; body.append('0', file, image.fileName);
I use react native and I don't know if my file object is correct.
I've been stuck for 2 days.... Thank you !