download zip file using Rest API responding null file immediately - spring

I have spring boot API for downloading zip file, when i hit rest API in IE or chrome, API responding with file name as null, with no content, if try to hit the same api again after few seconds, the file getting downloaded.
how to fix this issue.
Please help.
Thanks
Daya

this is due to the filename was set after the content(stream) was written to response, once content was written the control return back to client - before filename was set to the header.

Related

Tar.gz files are not extarcting in Google cloud bucket using Jmeter

I am trying to upload tar.gz files into google cloud bucket using jmeter. Here i am using File management service, GCS & Jmeter.
Execution flow.
1. Using get Request i am hitting FMS.In response I'll get response message. this response contains the URL to upload the file to GCS.
2. Now the file SJ311.tar.gz file is uploaded in the folder iviu/SJ311 folder in GCS.
3. In GCS cloud function is written a code which will extract the .gz file & all .csv files should be extracted successfully.
Issue : through POSTMAN i am able to do this i.e. file is uploaded & it is decompressing the tar file but using jmeter file is uploaded successfully but its not extracting/decompressing.
If you're able to send the request using Postman and see that JMeter behaves differently than it means that you're not sending the same request using JMeter.
Most probably this is due to missing or incorrectly defined HTTP Header so make sure to compare each and every detail of the request and given you send the same requests you should get the same behaviour/response.
Going forward if something is working in Postman and not working in JMeter you can just record the relevant request using JMeter's HTTP(S) Test Script Recorder, just configure Postman to use JMeter as the proxy and run your request, JMeter will capture it and properly build the HTTP Request sampler, add HTTP Header Manager, etc.
Just remember to copy the file(s) you will be uploading to the "bin" folder of your JMeter installation prior to recording, otherwise JMeter will not be able to capture the request.
Solution to the above question is, under File upload section-> under Parameter name field i added DOM attribute or webelement value for the "upload file" button which is present in Google cloud storage screen.
Now after removing that parameter value, file is getting uploaded successfully.
If we add the attribute value, file will get uploaded successfully but it will be corrupted.

How can Upload the Docx, Doc file on Cloud Server Storage

I have uploaded as per Oracle Documentation but didn't get in same format. here is postman screenshot next when get request for same file is here after getting from server.my docx file
please let me know what i missed. thanks in advance.
You used POST in your postman call, instead of PUT.
POST in this case is used as the command for creating or updating the metadata, not the object.
Try it with PUT instead.
See the Oracle Cloud Storage documentation for this as well.

Spring Boot on Windows, invalid temporary upload location

I have a web service built in Spring Boot 2.0.2 and deployed on a Windows 10 based machine.
One of the tasks of the application is to accept an image via a POST request and then move the image to a specific location on the system, i.e. c:\ftp. Initially the application works fine, however, after a period of being left, upon a new request I'm seeing the error below;
Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\\Users\\FRONTIER\\AppData\\Local\\Temp\\tomcat.10182171515108748004.8080\\work\\Tomcat\\localhost\\ROOT] is not valid
I suspect that Windows is deleting old temporary files/folders, resulting in the temporary upload path no longer being present.
Has anyone come across this issue before, and is there a way to fix it?
Hello SheppardDigital,
try adding the property
spring.servlet.multipart.location=C:\\Users\\admin\\Desktop\\Perfect_APP\\
to your application.properties file, this property sets the multipart temp location for uploaded files which the POST requests use.
Be sure to set an absolute URL.

Google Drive Rest API V3 Downloading large files with alt=media option (>25MB)

I am trying to figure out how I can download a large file directly in the browser via the Google Drive API V3.
I'm using option 1 which is : Download a file — files.get with alt=media file resource
When I send my request ( https://www.googleapis.com/drive/v3/files/[fileId]?alt=media), I got the content of the file as a response of it.
Currently I'm creating a blob file with the response of my query, then reading the blob file to start the download on the browser.
The problem with that is, reading the blob file consumes a lot of memory and if the file's size is more than 10MB, then browser crashes.
So my question is : how can I start the download on browsers via the Google APIs like mention on the screenshot bellow? See expected result
Try downloading the file in chunks using the range http header. See https://developers.google.com/drive/v3/web/manage-downloads "Partial download"

How to separate the files from Google Drive in the Response only using Rest API

Hi I'M new to windows phone Application development i'm working on how to get access the files from google drive using rest api i got the response in the response i got all the information like .pdf,.docs,mp3,mp4 ,folders etc...and the response is coming slow from the web for that is there any solution that.I should get response only that contains images and folders so that app will fast and accuracy... Thanks in Advance.
https://www.googleapis.com/drive/v2/files?q=mimeType contains 'image/jpeg'
The above link is for getting only images in this way according to mime type we can get the files rather than getting all files at a time

Resources