[File Transfer Plugin] Authenticated File Transfer

[File Transfer Plugin] Authenticated File Transfer

  
Forge Component
(4)
Published on 5 Mar by OutSystems Experts
4 votes
Published on 5 Mar by OutSystems Experts

Hi,


We are building a mobile application that needs to download files stored in the database server.


The file access is restricted and must be verified before the download.


How can this be achieved using the File Transfer plugin? Can the headers parameter be used? How can we send the needed Cookies and Cross-Site Request Forgery (CSRF) token?


Thank you in advance,

Renato

Hi Renato, assuming you are using the latest version of the plugin, namely version 2.1.0, you can use the action DownloadFileWithHeaders and pass the headers you need in order to download the file. The headers will be added to the HTTP request as HTTP Headers. See if it works for you.


Greetings, pedro

Thanks Pedro.


How do I get the headers need for mobile authentication?


From the link above these headers are:

  • nr1<User Provider Name>
  • nr2<User Provider Name>
  • X-CSRF-Token


Cheers,

Renato


Pedro Rodrigues wrote:

Hi Renato, assuming you are using the latest version of the plugin, namely version 2.1.0, you can use the action DownloadFileWithHeaders and pass the headers you need in order to download the file. The headers will be added to the HTTP request as HTTP Headers. See if it works for you.


Greetings, pedro



Hi Renato, if I understand you correctly, you want to be able to download files from the platform server itself. If this is the case, you don't need to use the File Transfer Plugin. You can do this using a server action that returns the binary of the file. The platform will make sure that the communication between client and server is secure.

I'm sending an example application. The application contains one single page. You can upload images to the server and you can download them. When an image is sent to the server, it is stored in the database. The identifier of the image is returned and presented to the user through a feedback message.You can use this identifier to retrieve the image. 

Hope this helps.

Greetings, Pedro

Hi Pedro,


Thanks again.


Your suggestion is what I implemented in the first place.


My goal is to receive / send files with the functionalities of File Transfer like background transfer and progress indication, which gives a better user experience.


Cheers,

Renato


Pedro Rodrigues wrote:

Hi Renato, if I understand you correctly, you want to be able to download files from the platform server itself. If this is the case, you don't need to use the File Transfer Plugin. You can do this using a server action that returns the binary of the file. The platform will make sure that the communication between client and server is secure.

I'm sending an example application. The application contains one single page. You can upload images to the server and you can download them. When an image is sent to the server, it is stored in the database. The identifier of the image is returned and presented to the user through a feedback message.You can use this identifier to retrieve the image. 

Hope this helps.

Greetings, Pedro



Hi Renato, if you rather want to use the File Transfer Plugin, you could issue a request to the server in order to obtain the info you need. Once at the server you can obtain the nr1<User Provider Name> and nr2<User Provider Name> from the Cookie request header and the parameter and the X-CSRFToken from the X-CSRFToken request header. I'm sending you a mobile application that exemplifies this. There is a server action that retrieves both of theses request headers. This server action is called from the homepage screen and the values of the request headers are shown on the screen. You could either store these values in the local store in order to use them when doing the call to get a file. As an alternative, you could do this call just ahead of downloading the file. Then you don't need to store it.

See if this helps.

Greetings, Pedro





Thank you for your time and example Pedro.


I'll give it a try and give feedback afterwards.


Cheers,

Renato


Pedro Rodrigues wrote:

Hi Renato, if you rather want to use the File Transfer Plugin, you could issue a request to the server in order to obtain the info you need. Once at the server you can obtain the nr1<User Provider Name> and nr2<User Provider Name> from the Cookie request header and the parameter and the X-CSRFToken from the X-CSRFToken request header. I'm sending you a mobile application that exemplifies this. There is a server action that retrieves both of theses request headers. This server action is called from the homepage screen and the values of the request headers are shown on the screen. You could either store these values in the local store in order to use them when doing the call to get a file. As an alternative, you could do this call just ahead of downloading the file. Then you don't need to store it.

See if this helps.

Greetings, Pedro






Hi Renato, do you have news on whether it worked?

Greetings, Pedro