AnsweredAssumed Answered

Upload a file REST Api

Question asked by UoC on Aug 28, 2015
Latest reply on Aug 31, 2015 by goeer03

Hi All.

 

Does anyone have any experience or know the best approach to upload a file via the API Gateway using http? I would like provide an API that then puts the file to a JMS queue.

 

I started with something like this, where I have an html form uploading using a post and enctype="multipart/form-data"

 

<html>

<body>

    <form action="https://api.company.co.nz/finance/upload" method="post" enctype="multipart/form-data">

        <label for="file">Select a file to be uploaded</label>

        <input type="file" name="file" /><br />

        <input type="submit" value="upload" />

    </form>

</body>

</html>

 

If its a text file I can get the contents using

request.parts.1.body

 

and some of the attributes using

request.parts.1.contentType

request.parts.1.size

 

However, this is as far as I can get.

How could I proceed with this so that I can get the file name/attributes? Would I need to add specific parameters/headers to the service which are set by the API Developer?

What about the contents for other file types? Do I need to encode the file Base64 and pass this?

 

Does anyone have an example or has solved this before or has advice or another recommendations?

BTW I am not looking for the ftp option.

 

Cheers,

Paul

Outcomes