loopback-component-storage doc for file (or files) upload says this: loopback documentation
Description:
Upload one or more files into the specified container. The request body must use multipart/form-data which the file input type for HTML uses.
Method:
upload(req, res, cb)
REST URI:
POST
/api/containers/:container/upload
Would someone please show an example of how to create this multipart/form request in Angular/Javascript?
Follow this rules when creating a multipart form: Specify enctype="multipart/form-data" attribute on a form tag. Add a name attribute to a single input type="file" tag. DO NOT add a name attribute to any other input, select or textarea tags.
Overview. The LoopBack storage component makes it easy to upload and download files to cloud storage providers and the local (server) file system. It has Node. js and REST APIs for managing binary content in cloud providers, including: Amazon.
Multipart upload allows you to upload a single object as a set of parts. Each part is a contiguous portion of the object's data. You can upload these object parts independently and in any order. If transmission of any part fails, you can retransmit that part without affecting other parts.
So, one of the things that LoopBack makes incredibly easy is handling data in a persistence system. You define a model, let's say Cat, various properties and types, and then LoopBack can handle persisting that in a variety of different storage mechanisms, from Oracle to MySQL to MongoDB.
You can go through code in Loopback Storage example git repository. It internally uses angular-file-upload library which would be beneficial in the future to add filtering on the type, size and number of files.
This example doesn't use lb-services
but uses direct calls using $http
module.
You'll be able to upload files using the example code. Please let me know in case you need to know angular-file-upload filters to filter out files based on size, type or number of files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With