83
Views
5
Comments
[Multipart/form-data] Need a sample oml file which can send file through expose API
multipart-form-data
Service icon
Forge asset by Kilian Hekhuis
Application Type
Reactive
Service Studio Version
11.54.57 (Build 63234)

Hi. I am still new to this platform. I am building a feature where i will upload multiple excel file using reactive multiple upload forge, then i want those uploaded files to be send through expose API using multipart/form-data forge to an external server.  I do not know how to implement this as there are very limited examples or demo for this. Can anyone here guide me on this one or share an sample oml file for this functionality?


my multiple file upload is exactly like in the youtube tutorial for this forge. I do have some questions too on this. when file is uploaded here, can we send it directly to the expose API, or we need to store this uploaded files into an database entity first, and then expose it through API?


For the multipart/form-data forge, i just refereed to the sample oml shared to here in this forum discussion. 

https://www.outsystems.com/forums/discussion/86983/multipart-file-upload-to-os-binary-file-results-in-error-when-using-xml-extension/


 thi is how the api and the method look like.  please help me on this one anyone?

2024-10-12 12-11-20
Kerollos Adel
Champion

can you attach your oml
and if i under stand you 
first ==> you can create structure  File with 2 attribute ( Name , Content )

second ==> create structure  files hold list of file structure   



in rest api make input ==> files and api type not get set file resiceve in body




UserImage.jpg
Alakendram Thirukkumaran A

Hi Adel. Thanks for the info. i will try this one and see. The OML i have currently i something i cannot share as it is in my organization's server. Maybe i can recreate it in my personal enviroment then share here it here. The screenshot the send, is the OML available for sharing, so that i can try to refer to it to see i can make my existing one work or not. Give me some time, i will share my personal OML soon 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Thirukkumaran,

Please use this component only if the built-in multipart/form-data functionality is too limited for you. Please first try the built-in functionality if you haven't already, thanks.

EDIT: It also seems that while you are saying you want to send files, you are using the functionality to receive multipart/form-data.

UserImage.jpg
Alakendram Thirukkumaran A

Hi Killian. It looks like the built in functionality for multipart is for consume api only. In my case i need to send an excel file uploaded into outsystems, to be sent to an external server through expose API. 



so this is how it looks...when user uploads file it will be like 

The variables and client action for this feature 

I followed this exactly like in the youtube tutorial. i believe file uploaded here only remains in the variable. not stored anywhere else within outsystems


so what i want is the uploaded files to be send to my external server through expose rest api. ..so this is where i am stuck.
first i want to know those files need to be stored in an entity or not. if yes, i doubt it can save multiple file uploaded in at once by a user can be stored as single record. 
Then from here i would like to know the way to create the expose api, so that i can send this files to my backend server which is an python api flask application. so when i consume this outsystems endpoint in my backend python application, it should be stored in a specified folder within the server.

is this possible?

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Alekandram,

You are asking a lot of questions, about a lot of different subjects. I'll try to answer them as far as space here allows:

  1. If you want to expose a REST API that receives multipart/form-data, you indeed need this Forge asset. It wasn't clear to me that you wanted to expose, rather than consume, a multipart/form-data API;
  2. Like with all REST APIs you expose, you receive the data from the caller of the API, and you need to handle that data. Basically, an exposed REST API method is just like any other Action, in that you need to handle whatever input you get;
  3. Whether you want to store the files in the database is up to you. In general, this is a good idea if you want to have them available or process them at a later stage;
  4. If you receive multiple files at once, you should probably store them in the database one by one (the alternative is just storing the entire received message, but I wouldn't do that);
  5. If you want to send files to another API, you are not exposing the API, but consuming it. So if you have an API set up in Python, you need to consume the Python REST API;
  6. If you consume a Python API, and you are sending files to it, storing those files is of course something your Python API must handle;
  7. You can store the files wherever the Python API can store them. Obviously, if Python is not running on your server, then you cannot store any files on that server.
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.