Upload service

Hello
I need to create a service, to be able to upload files to the server from an html or dsp page.
Can you tell me how to do this?
I am using version 10.5

Writing the service is the easy part, see here an example screenshot

You can use javascript from within in DSP or HTML page as such

<form enctype="multipart/form-data" action="/invoke/jc.demo/uploadFile" method="post">
    <input id="image-file" type="file" />
</form>

@John_Carter4 provides a nice and simple example to illustrate, but I would strongly suggest that you not use streamToBytes – that will load the entire file into memory, which can be bad. Just pass the stream you get in the pipeline to the file writing service. The data will go right to disk without exhausting memory.

@reamon - good point, this is a copy paste for a use case where I know the file will be a simple text file.
If you want to build something like this for public facing purposes, use a stream and also impose a file size limit too!.
thnx,
John.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.