How to ensure that fineuploader sends a streaming upload request instead of MPE request? - fine-uploader

I do not see any options to remove parameters or disable sending parameters when uploading using fineuploader. I can only override existing parameters or add new ones. Is there a way to do an upload using PUT without sending any parameters? Since I have signed PUT URI, I don't need to send the parameters. I tried using paramsInBody = false but that adds the content type "octet-stream" to the request. Amazon S3 returns unauthorized because of the incorrect content type.
Note: I am not using fineuploaderS3 since I need to upload to different endpoints.
Edit: Additional information
If the upload is not multi-part, fine uploader is adding the following header
xhr.setRequestHeader("Content-Type", "application/octet-stream");
This causes an authentication error with amazon S3.
I would like not to send default parameters like qquuid, qqparentsize, qqfile and qqfilename in the body since only file data is expected in the body. Setting paramsInBody to false sends them in query string. This works because the URL parameters are ignored by S3 but I would prefer to have an option to not send them at all.

By default, Fine Uploader sends all files as part of a multipart encoded request. To instruct the library to simply send the file as the entire request body, you must set the request.forceMultipart option to false.
Note: It is not possible to prevent uploads sent from IE9 and older to be non-multipart encoded. The only way to upload a file in IE9 and older is via a multipart encoded request.

Related

Download different content types with spring

I need to expose a POST endpoint where the user uploads an excel file and based on some validations, I either send back the file with some information added to it along with json response OR just send status code as 200 OK(no data).
I am trying to do this in spring boot. I tried following link:
https://javadigest.wordpress.com/2012/02/13/downloading-multiple-files-using-multipart-response/
This works but needs adding boundary manually. Is there any other way to do it so that I can send both the data ?
You should use #Produces as it is written here: https://docs.oracle.com/cd/E19776-01/820-4867/ghrpv/index.html
You can define the MIME-Type of your payload.

Jmeter: How to override Content-Type in request to sent multipart/form-data

In all my requests I need Content-Type=application/json, so I added HTTP Header manager under the Test Plan.
But then inside of one of the threads, I need to upload image as a multipart request with additional parameters. I created HTTP request sampler, checked 'Use multipart/form-data', added file on File Uploads tab, added parametres on the Parameters tab. But Content-Type=application/json was sent in headers, so the request was failed.
I tried:
To add additional HTTP Header manager under the request with
Content-Type=multipart/form-data;
boundary=----WebKitFormBoundary6dcBYcLBBPisdP1e. But in the body of
the sent request, Jmeter added another boundary (randomly generated)
so the request was failed
To add Content-Type=multipart/form-data without boundary, but it didn't work (error that boundary is required)
To write body of multipart request myself, so my boundary is used. It worked for txt files, but I had problem with reading data from image file, so all images were broken when loaded (I used ${__FileToString(${pathToImage},,)} to read file content and add it the request body).
Is there any option to override content type as multipart/form-data and to add boundary that will be then used by Jmeter in body? I can remove the header manager from the test plan, in that case multipart request will be sent with Content-Type=multipart/form-data; boundary=----%randomly_generated_by_jmeter%. But in that case I'll need to add application/json content type to all other requests (and there are lot of them).

Upload image to Lambda using gateway API

I'm trying to let user upload pictures to a lambda function for processing; using the gateway API interface.
I tried to specify a model for my POST method, but so far I keep getting the error
Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
... Not so helpful.
I understand that I cannot directly send raw data to lambda and must using some kind of formatting in-between.
What I understood is that I could make the gateway interface base64 encode the data for me.
I tried to do so by using the following model schema with the content type image/jpeg
{
"body" : $util.base64Encode($input.body)
}
How to send the image ?
There is no native support in API Gateway for binary data as you have seen. We are working on this but I don't have an ETA for you. Some customers have had success base64 encoding the data like you have in your question, only it should be in a mapping template in the Integration Request not the Method Request.
If you set the content type to image/jpeg, then the encoding will apply only when the Content-Type header on the incoming request is also image/jpeg, so make sure to set that.
You can also reject incoming requests to the method that don't send the right Content Type by setting the 'Request body passthrough' (passthroughBehavior in the API) to the recommended value ("when there are no templates defined" or 'WHEN_NO_TEMPLATES' in the API)
Docs for the passthrough behavior -> https://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#passthroughBehavior
Since it seems like working with binary data and API Gateway is complicated, I think you should:
Upload the image using API Gateway as an S3 proxy
Set a trigger for your lambda function on PUT for the bucket where you've uploaded the image

Retrieve JSON response when creating video on Brightcove

I followed the example on http://docs.brightcove.com/en/video-cloud/media/references/reference.html#Video. The response gets shown in an iframe. However, I would like to be able to get the JSON response in order to store the data (i.e., Brightcove video ID) in my own database. I tried using AJAX post but Brightcove doesn't seem to accept post requests from a different origin. Is there a way to simply get the response data without displaying it in an iframe or in a separate window?
You can't get the response data in javascript since the API response does not include CORS headers. You'd need to do this in server-side code, which also has the advantage of not exposing your API token to the browser.

Fine Uploader get response before onComplete

I am having problems with IE9 to get a json as response. In the service it returns a json but in the network in IE9 I see an XML. So, the responseJSON parameter in OnComplete comes without the response.
Is there any event before OnComplete? I want to parse the XML to json in the client side when it is IE9 or older.
I am using Fine-Uploader in basic mode.
Regards,
You will need to figure out how to return JSON from your server. Fine Uploader expects a valid JSON response and this is non negotiable. There is an open feature request that will allow integrators to contribute their own response parser, but this is a relatively low priority feature and it really doesn't apply to your situation. Your best bet is to get control of your server and ensure the response is returned in the proper format.

Resources