async MediaUpload(photos : any[]) { const client = await this.Login() const full_photo_urls : string[] = photos.map((item) => item.full) let image_ids : string[] = []; full_photo_urls.forEach(async (image_url) => { const image_blob = await fetch(image_url).then(res => res.blob()) try { console.log("images are about to be posted!"); const image_res = await client.postMediaAttachment({file: image_blob}) console.log("Images were posted here"); console.log(image_res); } catch (error) { console.error(error); } }) return image_ids;

Runs Error block which results in this

{ failed: true, json: { id: '111037763715692057', type: 'image', url: 'https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/original/c46fd6ce6b892c66.jpeg', preview_url: 'https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/small/c46fd6ce6b892c66.jpeg', remote_url: null, preview_remote_url: null, text_url: null, meta: { original: [Object], small: [Object] }, description: null, blurhash: 'UEHo8yIm%gV?9Exv%fM{?u~qM_D%xvITM{xa' }, path: 'media', response: Response { [Symbol(realm)]: null, [Symbol(state)]: { aborted: false, rangeRequested: false, timingAllowPassed: true, requestIncludesCredentials: true, type: 'default', status: 200, timingInfo: [Object], cacheState: '', statusText: 'OK', headersList: [HeadersList], urlList: [Array], body: [Object] }, [Symbol(headers)]: HeadersList { cookies: null, [Symbol(headers map)]: [Map], [Symbol(headers map sorted)]: null } }, status: 200, rateLimit: 30 }

I am really confused given it gives me a status code 200 which means OK, but still says it failed??? I also used my debugging to understand this is the line where the error occurs

const image_res = await client.postMediaAttachment({file: image_blob})

also ignore the fact imageres is unused, I removed the code after it for testing since to ensure nothing else was causing the error

  • bailu@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    10 months ago

    One thing to check is the mime-types of the uploaded file and the source. I had a squirrel-y issue with my S3 bucket src files not having the correct content type