Upload a file in a Telegram Bot

(Seve Ho) #22

Hello @To_Huy Can you please share your solution? Or at @DanielBeckett or anyone of the support team can you please provide documentation of how to get the FormData object of an uploaded file so that I can use it inside a webhook?

(Daniel Beckett) #23

Hi @SeveHo

To capture an uploaded file you’ll need a flow that’s using the ‘New File’ trigger. In that flow, once a file has been uploaded there will be an output for the file URL that ca be used in other actions.

Is that what you’re looking for?

Thanks,
Dan

(Seve Ho) #24

Hi @DanielBeckett,

kind of.
In order to upload the file to an other destination I need something like a Blob, FormData or File object. So I’m struggling with figuring out on how to get an object like this from the file url.
If I do a GET request on the file url I get the raw file inside the body of the response. But after that I dont’t know how to use the raw body to upload the file again as multipart/formdata to a desired destination.

Regards,

Severin

(Sarah Palombo) #25

Unfortunately you can’t access any objects or data to be able to ‘get the file’

When the new file is triggered, The only outputs available are:
File URL
File Type
file_name
file_extension": “pdf”,
file_type": “application/pdf”,
file_size": 83453,

The way to do this, is to have an online service that you can use to forward the file URL. this service would then need to get and save the file. To_Huys screen shot above shows that he’s forwarding a file using the HTTP service (which is the right way). I don’t know what kind of services there are to suggest unfortunately but that would be the idea :slightly_smiling_face:

Sarah

(Seve Ho) #26

Ok thanks for the help!

How long are the files saved on the server?
And it would be also nice to have some kind of protection so that only bot owner can access the files related to their flows. Something like an access secret.

(Daniel Beckett) #27

Hi @SeveHo,

How long a file will be stored for depends on the messaging platform. Unfortunately, I can’t find any definite answers for Facebook Messenger or Telegram.

On the Web Messenger there’s a Maximum file size of 20MB per upload and the files are retained for 30 days.