0
votes

My goal is to get the image from Twilio api to store it somewhere else because Twilio deletes media after 4h. (See here)

I'm using node and I have read https://www.twilio.com/docs/sms/api/media-resource#fetch-a-media-resource

...and it says that to do a request to this URL without the "json" extension should return the media with its original MIME type

https://api.twilio.com/2010-041/Accounts/{AccountSid}/Messages/{MessageSid}/Media/{Sid}.json

However, i need auth, so I need to use

const client = require('twilio')(accountSid, authToken);

How can I fetch the image? Any sample code to achieve it? In the docs seem to do it without auth.

UPDATE ----------------------------------------

After accessing the MediaUrl0 on the browser, twilio redirects me to the following URL:

https://s3-external-1.amazonaws.com/media.twiliocdn.com/{AccountSid}/{?}

I was thinking of building my own URL but i dont know how to get the {?}

1

1 Answers

0
votes

You do not need authentication to retrieve media for an incoming sms . They are all hosted (as of now on Aws S3) and accessible publicly through a (hard to guess) url. you can access them using any http client