Posting formdata files to an IS 46SP1 service

Has anyone successfully posted MS files from a web page to a IS service to be saved onto the server’s disk drive? Here’s the scoop:

  1. build a web page that has a form with method=“POST”, action="/invoke/(someService)", and enctype=“multipart/form-data”. In this form have input variables and at least one input field with type=“file” (this lets the user specify a file to be uploaded by the user’s browser).
  2. the (someService) service accepts the MIME stream posted by the form and parses out the input variables (stored in a db) and the files (stored on the server’s disk drive) based on the MIME boundary definition.
  3. in another service, the server builds multipart MIME streams to be sent with the pub.client:smtp service with the file(s) read-in from the server’s disk attached and the variables specified included within the html body of the message. An expiration date can optionally be applied to the outgoing message.

So, I have step 1 and step 3 nailed, but step 2 is giving me problems. I can parse the variables, and I can parse the files, but MS word and MS Excel files appear slightly mangled. Text files and image files (GIF & JPG) work fine. It seems that sample.mime.helpers:streamToString may be altering the stream in some tiny way. Are the MS files different enough to confuse the streamToString service?

The MIME stream posted from the form (as opposed to being sent via e-mail) is different enough to cause the sample.mime:extract_MultipartMIME service to not detect the parts. The pub.flow:getTransportInfo looks okay, but I need to invoke the streamToSting service in order to separate the bodyparts using the boundary by hand, since the default content handler doesn’t split-up the MIME message correctly, as it does with the e-mail MIME, i.e., with e-mail it invokes the service for each body part individually.

Any clues would be appreciated…

Hi, Chris. We are working on this issue, too. If you figure it out, post your solution. I promise to do the same.

Thanks.

Chris,

You may want to post the data to the server using Base64 Encoding and create a custom content handler (Thanks Igor) to handle this. Ideally, you could base 64 encode just the data that is part of the file upload and then assign a special content handler to persist and then obtain the attachment data. Will this work?

ray

Actually, I’m talking to wM Tech Support about this (GSun). She sent a tiny flow service that will grab, from the pipeline-in, a variable with the same name as the name of the form’s file input variable (in the form: [input type=“file” name=“upFile”], “upFile” in this case), passes that variable’s “data” node to pub.string:bytesToString, maps that string to a variable, then that variable is picked up by a Java service to be written to disk. I modified it to loop through “upFileList” instead, named all of my file input types within the form “upFile”, and was able to get working Excel, Word, & Visio files on the other end (sitting on the server machine) all from the same form!! However, I still need the content-type of each file in order to construct the outgoing MIME message properly when attaching those files, so that’s why the SR is still open…! :wink:

As far as posting the file contents to the server as base-64, I’m not sure how to do that. It seems that, ultimately, I’d be in the exact same boat – parsing through the posted data by hand based on the Boundary string of the multipart form-data. The form-data is separated by boundaries, just like a SMTP-posted MIME stream’s body parts (missing only the overall MIME header), so it seems that pub.mime’s routines (getNumParts, getBodyPartHeader, getBodyPartContent, etc.) should be capable of working on HTML-posted MIME, too…

I’ve resolved this problem, and I can post multipart/form-data to IS using the slightly modified content handler that GSun sent that can grab any kind of html form input variable, including files.

The form’s input variables’ name/value pairs are extracted and stored on the DB, and the files are copied to the server’s hard drive, and the file’s name (and location on the server), content-type, and form input variable’s name are stored on the DB. Later, in a separate processing service, this stored information is constructed into an email message containing all of the original form’s content assembled into a mimeStream and passed to the pub.client:smtp service in a separate thread. The files show up (intact!) as attachments on the e-mail. This Outlook message can optionally expire.

The only thing that I don’t like about this solution is that I have to create a unique service associated to each different type of form in order to be able to access each form’s data elements within the receiving flow service. I had wanted to have a generic service, but this will do for now…

Hi,
i need your help.
can u guys tell me how you are readiing the multipart mime message. I am getting a mime from a file using getFile and then extracting the data am using the createMime service. My problem is that my file is of 1.5mb and is failing at the create mime step. Saying out of memory exception and also failing saying client.NSRuntimeException.
can you give me any suuesstions in this.
Thank you in advance…

Chris,

Related on your solution to post form-data files to IS, could you send me the flow service that GSun sent to you, that can grab any kind of html form input variable or tell me where I can retrieve it ?

Thanks a lot for your help

Chris,

Could you send me the flow service. I also need to handle the Posting form-data files to an IS 4.6 service .

Thanks

Chris,

I will join the crowd. I am already spending 1 day on this. I read your comments and I need to upload files in our serves the same way you described. Pls, can you send me a package with the flow services you are using (if I am not asking too much!). This is will be a time saver, big time.

Thanks!

Help,

I need to know how the “tiny flow service” mentioned above by Chris works and how it will grab, from the pipeline-in, a variable with the same name as the name of the form’s file input variable (in the form: [input type=“file” name=“upFile”], “upFile” in this case), passes that variable’s “data” node to pub.string:bytesToString, maps that string to a variable, then that variable is picked up by a Java service to be written to disk. How can I build the same solution described?

Anyone can post the source code or send me a package with an example? Any way will help.

Thanks,

Waldes

Hi Waldes,

I have the samples package which doing the upload file content ‘multipart/form-data’ using MIME service. But i need to cut the additional information at the end of the file. And when the upload file is binary, the content of the file will be modified. (using bytesToString).

Rgds,
Pang

Hi,

Could someone send me the flow service. I also need to handle the Posting form-data files to an IS 4.6 service.

Thanks

I know this thread is 2 years old, but can anyone send me the ‘tiny flow service’ as I want to exactly the same upload from a .dsp page

regards

graham moisley
graham.moisley@bizaps.net

Folks, iam having the same problem while uploading. MIME Stream has been successfully posted and stored in disk, but was unable to open gif files and excel files with gif content in it. Can any body send the sample(s).

Cheers,
sr1n1k@yahoo.com

Hi Folks,

I am looking for a service to parse the xml files (with multipart ) but to no avail.

Greatly appreciate it if there is any kind soul willing to offer a helping hand.

rdgs

Gary

Hi Friends,

can anybody of you send me the so called “tiny flow service”, that can submit multipart/form-data.

My Email is : Amrendra.Kumar@colt-telecom.com

Thanks a Lot.
Amrendra

Friends,

Any luck in finding a service to parse the xml files (with multipart). Please inform me too - shency@gmail.com

Thanks!