How to capture file upload Content from dsp page

Hello experts,

I need to upload file from a DSP page, I have created:

  1. a DSP page with form that sends data to upload.dsp page
  2. upload.dsp page that calls IS service to handle the file

I can see in the pipeline name of the file, but content is not coming.

3)but how to catch that content into the is service ? i tried using tracePipeline but content is not coming.

please help how we will catch the content into the service pipeline.

The service should be receiving a contentStream, from which you can start reading or writing locally.
e.g.

Can you include your DSP page ?
regards,
John.

@John_Carter4 I have used contentStream as input, still it is not coming and throwing error (Missing Parameter: inputStream).

Attached DSP in .txt
fileUpload.txt (418 Bytes)
extension as this forum is not accepting .dsp file.

You need to add the following to your FORM declaration ‘enctype=“multipart/form-data”’

e.g.

<form method="POST" enctype="multipart/form-data"

You will then need to use the mime services to extract the content e.g.

Thank you @John_Carter4 it’s working after adding those declarations

@John_Carter4

I am getting the below line at end of the content. How can I get rid of this line.

------WebKitFormBoundarylqskd07qksdjl–

Hmm, me too.
It might be a bug I will need to look into this.
regards,
John.

1 Like

@John_Carter4 How to pass input parameters (text, select, etc) along with file uploaded content to flow service via dsp when using post method in form?

Hi @Warrior_S - you would need to use multipart handling. I might have a sample I can share here. I will look at the samples and attached here.

if the additional data is limited, then you could always use query params or headers. Otherwise you need to send multiple pars as @srikanth.prathipati1803 indicated.
regards,
John.

1 Like

@srikanth.prathipati1803 thanks, can you please share the example so that I can use.

@John_Carter4 thanks. Can you please share if you have any sample snippet for query parameters or headers.

Do you mean example code to generate this ?
or example such as a request ?
e.g.

MIME-Version: 1.0
Content-Type: multipart/mixed;
        boundary="XXXXboundary text"

This is a multipart message in MIME format.

--XXXXboundary text
Content-Type: text/plain

this is the body text

--XXXXboundary text
Content-Type: text/plain;
Content-Disposition: attachment;
        filename="test.txt"

this is the attachment text

--XXXXboundary text--

or

POST / HTTP/1.1
Host: localhost:8000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __atuvc=34%7C7; permanent=0; _gitlab_session=226ad8a0be43681acf38c2fab9497240; __profilin=p%3Dt; request_method=GET
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 554

-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="text"

text default
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain

Content of a.txt.

-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html

<!DOCTYPE html><title>Content of a.html.</title>

-----------------------------9051914041544843365972754266--

the command curl is capable of sending multiple files via mime attachments e.g.

$ curl -F "text=default" -F "file1=@a.html" -F "file1=@a.txt" localhost:5555/invoke/jc.test:receive

John.

Forgot to add that for a DSP page all you need to do is add more form inputs and the request will automatically be submitted in multiple parts as below.

------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
Content-Disposition: form-data;

name="name" text 
------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
Content-Disposition: form-data; 

name="description" description 
------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
Content-Disposition: form-data; 
name="fileName"; 
filename="test.txt" 
Content-Type: text/plain 

test file 
------WebKitFormBoundaryFLBl4kVBtl3F5yWC--

Interestingly each input value gets its own part and not not grouped as form data, perhaps there is a way of changing that.
John.

TryIt.zip (96.6 KB)
Do refer to TryIt.v3.services.pub:processFile @Warrior_S
Each part needs to be handled separately
image

1 Like

each one will be in a separate contentPart with a Content-Disposition called form-data
e.g.

------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
Content-Disposition: form-data;

name="name" text 
------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
Content-Disposition: form-data; 

name="description" description 
------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
Content-Disposition: form-data; 
name="fileName"; 
filename="test.txt" 
Content-Type: text/plain 

test file 
------WebKitFormBoundaryFLBl4kVBtl3F5yWC--

Use pub.mime:getBodyPartContent for each one.

regards,
John.

@srikanth.prathipati1803 I have used your code and finally it worked. Below services are key part before createMimeData in order to capture the content correctly.

pub.flow:getTransportInfo
pub.mime:mergeHeaderAndBody

@John_Carter4 thank you for your consistent help.

1 Like

Glad to know it worked, lot of consultants does not know to process multi-part data in webMethods.