Jump to content
Brian Culverwell

example of multi-part form containing headers, body (parameters) and a file to upload

Recommended Posts

Hi

I am trying to write code that will compose a REST request that is multi-part - containing headers, parameters (body) and a file to upload - then interrogate the response.

 

I have tried the inbuilt .net components of Delphi - and can create the headers and parameters, but the 'addfile' fails.

 

Any idea's or a sample project or code snippet that does this?

Regards

Brian 

Share this post


Link to post

Currently, the ICS REST component sample does not include file uploading, only building, sending and parsing parameters. 

 

There is an old non-SSL sample \WebDemos\ OverbyteIcsHttpPost.dpr that illustrates four different methods for uploading a file using POST, including multi part MIME, which may be tested against the ICS web server samples to receive files. 

 

It really needs combing with the OverbyteIcsHttpRestTst.dpr sample for modern use.

 

Angus

 

Share this post


Link to post

I think I've come across the things you describe when creating xxm. There's more to the project than REST, but to have an out-of-the-box option of hosting web projects created with xxm, I created a really basic HTTP server, that also handles multipart file uploads. So, if you have a web form like this that would allow a user to post a file, the server would process the parts of the request into specific parameters like this. But I'm afraid this is quite an integrated solution and not quite a 'snippet' you can use to apply elsewhere. None-the-less I warmly invite you to take a good look at xxm and see if it could be a fit for any project you're considering that combines Delphi and the web.

Share this post


Link to post
On 4/2/2022 at 2:51 AM, Brian Culverwell said:

I have tried the inbuilt .net components of Delphi - and can create the headers and parameters, but the 'addfile' fails.

Can you share some code that fails? With exact error message you receive?

 

Thanks.

Ertan

Share this post


Link to post
On 4/2/2022 at 7:24 PM, Angus Robertson said:

Currently, the ICS REST component sample does not include file uploading, only building, sending and parsing parameters. 

 

There is an old non-SSL sample \WebDemos\ OverbyteIcsHttpPost.dpr that illustrates four different methods for uploading a file using POST, including multi part MIME, which may be tested against the ICS web server samples to receive files. 

 

It really needs combing with the OverbyteIcsHttpRestTst.dpr sample for modern use.

 

Angus

 

Thanks Angus - I will take a look at that old non-SSL sample - at the moment I don't need SSL at all.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×