breezy-belgium-57865
04/15/2025, 3:52 PMorange-egg-72655
04/16/2025, 1:40 PMjs
const response = await axios.get(url, {
headers: {
Authorization: `Bearer ${env.accessToken}`
},
responseType: 'arraybuffer'
});
and then you would have to use files api to uploadbreezy-belgium-57865
04/16/2025, 1:41 PMorange-egg-72655
04/16/2025, 1:42 PMorange-egg-72655
04/16/2025, 1:42 PMbreezy-belgium-57865
04/16/2025, 1:42 PMbreezy-belgium-57865
04/16/2025, 1:43 PMorange-egg-72655
04/16/2025, 1:45 PMorange-egg-72655
04/16/2025, 1:46 PMbreezy-belgium-57865
04/16/2025, 1:47 PMorange-egg-72655
04/16/2025, 7:01 PMbreezy-belgium-57865
04/16/2025, 7:21 PMorange-egg-72655
04/21/2025, 1:55 PMshy-caravan-44867
05/19/2025, 2:21 AMmid query param as your media ID
const urlObj = new URL(imageUrl)
const mediaId = urlObj.searchParams.get('mid')
if (!mediaId) throw new Error('Could not extract mediaId from imageUrl')
// 3) Exchange mediaId for a fresh download URL
const infoRes = await axios.get(
https://graph.facebook.com/v19.0/${mediaId},
{ headers: { Authorization: Bearer ${token} } }
)
const downloadUrl = infoRes.data.url
if (!downloadUrl) throw new Error('No download URL returned by Graph API')
// 4) Fetch the bytes from that URL
const fileRes = await axios.get(downloadUrl, {
headers: { Authorization: Bearer ${token} },
responseType: 'arraybuffer'
})
// 5) Turn it into Base64 + capture MIME type
const mimeType = fileRes.headers['content-type']
const base64Image = Buffer.from(fileRes.data, 'binary').toString('base64')
// 6) Store for your Vision/LLM card
workflow.fileType = mimeType
workflow.base64Img = base64Image
console.log([ImageAnalysis] got ${mimeType}, base64-length=${base64Image.length})
const dataUri = `data:${mimeType};base64,${base64Image}`;
workflow.encodedImage = dataUri;