Loopback component storage cannot open downloaded file response body






















Calling the php service directly via browser allows me to download the file correctly. RipkensLar , i got the problem with empty file before, but after I switched to use fs.

When looking up the issue, I found someone uses some libraries to create a PDFDocument and load the file. In project A written in PHP the users are able to upload and download pdfs. This is working and used in production quite some time. Currently I am setting up another project where I need to access the database from project A because I need the same pdfs and don't want to store them twice. So I wrote a service which delivers me the pdf from the database from project A, and in my controller I send this data via.

But as stated above the pages remain blank. Calling the service in project A directly via browser give me the correct pdf. I also compared the raw data of the pdf and it is the same in the service in project A as well as in my controller in the loopback project. I suspect that OpenApi destroys the encoding when it sends the response, but I am running out of ideas. Steps to reproduce: Check out my repo. Switch into branch pdf-bug. Npm install. Npm start. Open the api-explorer.

As you can see the file is empty. The pdf data which I use in the controller method is the data I receive from my php project api. RipkensLar the file is not empty as seen in this screenshot. If it is not displaying any content in PDF viewers, something must be wrong in the format. Do you have any ideas how I could troubleshoot this? RipkensLar the PDF problem you have described is off topic here, can you please open a new issue please? Use case: I have large files stored on the drive, but they are sensitive, so I don't want to use this.

I need to check access rights first. But I do want to take advantage of static's streaming and caching features. For example it can also support HEAD requests for skipping to the middle of the content. Loopback could help by providing this serveStaticFile function. The function would handle any caching and skipping concerns, just like the current static routing does. Update: I notice that this. Use case: I have a large file in a repository, and I have also stored a checksum for it there.

If the header value matches the stored checksum, that means the browser already has the file, and I can reply with Not Modified. If not, then I must stream the file as normal and I will also pass the checksum in the response etag header. Option 1 offers the most flexibility. But an implementation of number 2 might suit a majority of use cases. If etag works, does anyone care about last-modified? Any documentation or example. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 4 years, 11 months ago. Active 4 years, 11 months ago.

Viewed times. Community Bot 1 1 1 silver badge. Try setting the header manually first and update your question — Jeroen Heier. Please use Fiddler to check the request headers and the actual values. Add a comment. Active Oldest Votes. Gary Liu Gary Liu Can you please help me? Skip to content. Star New issue. Jump to bottom. Labels feature. Copy link. It expects the stream is returned from the method call instead of the callback It only handles the stream, not headers such as Content-Type.

Member Author. Could you share how you implemented gridfs storage? Hi bajtos I'm currently trying to download a file from the backend API loopback3. UTC , 4, 1 , true, 3. UTC , 6, 9 , false, 1. Sign up for free to subscribe to this conversation on GitHub. Already have an account?



0コメント

  • 1000 / 1000