Loopback download file






















Permalink master. Branches Tags. Could not load branches. Could not load tags. Raw Blame. Open with Desktop View raw View blame. Nice to have: a helper function similar to res. Documentation: explain how a route can specify the response headers and provide body as a readable stream. Estimation meeting's discussion: We already allow the controller function to return buffer. Add some acceptance test case to demo an endpoint for file downloading.

Member Author. We already allow the controller function to return buffer. Is there any workaround to make stream response atm? Discussing with bajtos on the above comment , the code in the HomePageController that makes download possible are: constructor inject PackageKey private pkg: PackageInfo, inject RestBindings.

Edit: When I receive the file in loopback, it throws the following error: Malformed UTF-8 characters, possibly incorrectly encoded. 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 this. That's a PDF file format problem, so no idea.

This looks like a character encoding charset problem to me. What database are you using? What column type is used to store PDF documents? Is it binary, varchar, something else? What character encoding is your database configured with? What is your model definition? In particular, how is defined the model property holding PDF data?

Is it a string? A Buffer? You may need to include charset, e. The charset value utf-8 in my example , must match the encoding used by the PDF content. Suggestion: Allow us to call out to the static file delivery Use case: I have large files stored on the drive, but they are sensitive, so I don't want to use this.

Example of how I might like to use it: I add a controller route which does access checking, and if access is granted, then I pass the request off to the static handler. Suggestion: Support caching when delivering from DB Use case: I have a large file in a repository, and I have also stored a checksum for it there. The client requests the file from our API, also passing an etag header. Loopback can help either by: Provide example code for how to do this, OR Provide a function that will do this logic for us when called.

The FileUploadService is configurable to support various storage engines. We also apply requestBody. The injected request and response objects are passed into the multer handler to process the stream, saving to.

See more details about requestBody. Our example implementation simply returns an array of file names under the. LoopBack Web Site. Please provide the ad click URL, if possible:. Oh no! Some styles failed to load. Help Create Join Login. Application Development. IT Management. Project Management. Resources Blog Articles. Menu Help Create Join Login.



0コメント

  • 1000 / 1000