Image format in every actors
# apify-platform
b
Hi, I was wondering, why when I use the instagram Scrape actor, or the facebook or even the tiktok actor, the displayURL in the JSON is an instagram,facebook,tiktok link but when I click on it from the output response it's an apify link? How can I always have the apify link in my code?
m
Hey, could you provide a specific example, please? I am a bit lost...
b
Yes of course, let's take for example the instagram scraper. If I go look at the output in json format, I have this url in the field "displayUrl": "https://scontent-dfw5-2.cdninstagram.com/v/t51.2885-15/544285548_1441711007093848_9054364840506460506_n.jpg?stp=dst-jpg_e15_tt6&_nc_ht=scontent-dfw5-2.cdninstagram.com&_nc_cat=104&_nc_oc=Q6cZ2QE3KGTOkwIKbmV-05wyk30aRoIF88gzbmJVFjhGJQMY3TJX3dP2qhFF0_G8ChQfZ3w&_nc_ohc=8QJR21slVIAQ7kNvwEmZXPF&_nc_gid=rRfGklzR2Ig-U7zUYVCAAw&edm=APs17CUBAAAA&ccb=7-5&oh=00_AftPTlhWllexpwNZMt85X6RDl0Is-Q0SVBwVuIofpEcGng&oe=699972CF&_nc_sid=10d13b", But if I look at the table result output and press on the image (see the screenshot), I get this link:

https://images.apifyusercontent.com/o7pg6PZ-8w3yE32-JjfoPEsQqVHHb-4nT54oOGoCq8k/cb:1/aHR0cHM6Ly9zY29udGVudC1kZnc1LTIuY2RuaW5zdGFncmFtLmNvbS92L3Q1MS4yODg1LTE1LzU0NDI4NTU0OF8xNDQxNzExMDA3MDkzODQ4XzkwNTQzNjQ4NDA1MDY0NjA1MDZfbi5qcGc_c3RwPWRzdC1qcGdfZTE1X3R0NiZfbmNfaHQ9c2NvbnRlbnQtZGZ3NS0yLmNkbmluc3RhZ3JhbS5jb20mX25jX2NhdD0xMDQmX25jX29jPVE2Y1oyUUUzS0dUT2t3SUtibVYtMDV3eWszMGFSb0lGODhnemJtSlZGamhHSlFNWTNUSlgzZFAycWhGRjBfRzhDaFFmWjN3Jl9uY19vaGM9OFFKUjIxc2xWSUFRN2tOdndFbVpYUEYmX25jX2dpZD1yUmZHa2x6UjJJZy1VN3pVWVZDQUF3JmVkbT1BUHMxN0NVQkFBQUEmY2NiPTctNSZvaD0wMF9BZnRQVGxoV2xsZXhwd05aTXQ4NVg2UkRsMElzLVEwU1ZCd1Z1SW9mcEVjR25nJm9lPTY5OTk3MkNGJl9uY19zaWQ9MTBkMTNi.jpg▾

In my code, I receive the JSON response, is there a way to always receive the second link (the one from apify) instead? The run: https://console.apify.com/actors/shu8hvrXbJbY3Eb9W/runs/m9vbhifdi1IsIRmwp#output https://cdn.discordapp.com/attachments/1473068369560211476/1473320620430196839/image.png?ex=6995c840&is=699476c0&hm=466087af3b359f7894917904248383ee51e93af2663e9f2a90141d99c584aa79&
m
Ah, I see what you mean. Basically, this is a feature of our Apify Console UI. When you include an image URL in your output, our UI will download the image and display it in the resulting table, making it look better. But the "real" data is just the URL string. You can't always rely on this; some images might be broken or something, but you can always rely on the fact that your dataset will contain the exact data you put there. So no, you can't include this link in your code, since it will be generated after your results are added to the Dataset... Your other option is to save the image into the Key Value Store, and that way create your own Apify link like
https://api.apify.com/v2/key-value-stores/<ID>/records/<record-key>
b
No I didnt want to rely on it, it's just that when I want to download the image from instagram or other platform the proxy can stop me and I should not have this problem with apify. This is why I wanted the apify link, so I would download the binary from the apify link instead
Is there an example how to use the other option you explained?
m
Note that the same problem could have the UI...
It depends, but it would be something like this:
Copy code
Typescript
await Actor.init();
const res = await fetch(imageUrl);
const buffer = Buffer.from(await res.arrayBuffer());

await Actor.setValue('my-image.jpg', buffer, {
  contentType: 'image/jpeg',
});
b
Ok ok good thank you
a
message has been deleted
6 Views