Uses mongoDB GridFS to manage binary contents of your loopback application.
- https://github.com/strongloop/loopback-component-storage
- https://github.com/jdrouet/loopback-component-storage-mongo
- https://github.com/jdrouet/loopback-component-storage-gridfs
-
Files are identified by id, not by file name. So it is possible to have files of the same name in one container.
-
Files are identified by filename too.
-
Delete file chunks on file or container erasing.
-
Download file in line mode.
npm install --save loopback-component-storage-mongo-gridfs
Add datasource to your datasources.json
"storage": {
"name": "gridfs",
"connector": "loopback-component-storage-mongo-gridfs",
"host": "hostname",
"port": 27017,
"database": "database",
"username": "username",
"password": "password"
}
username and password are optional
GET /FileContainers
FileContainer.getContainers();
DELETE /FileContainers/delete/:where
FileContainer.delete({
where: 'where'
});
DELETE /FileContainers/:containerName
FileContainer.deleteContainer({
containerName: 'containerName',
fileId: 'fileId'
});
- containerName - name of container to delete
GET /FileContainers/:containerName/files
FileContainer.getFiles({
containerName: 'containerName'
});
- containerName - name of container
Errors:
- 404 File not found.
GET /FileContainers/:containerName/files/:fileId
FileContainer.getFile({
containerName: 'containerName',
fileId: 'fileId'
});
- containerName - name of container
- fileId - id of file
GET /FileContainers/:containerName/getFileByName/:filename
FileContainer.getFileByName({
containerName: 'containerName',
filename: 'filename'
});
- containerName - name of container
- filename - name of file
DELETE /FileContainers/:containerName/files/:fileId
FileContainer.deleteFile({
containerName: 'containerName',
fileId: 'fileId'
});
- containerName - name of container
- fileId - id of file to delete
DELETE /FileContainers/files/:fileId
FileContainer.deleteFileByFileId({
fileId: 'fileId'
});
- fileId - id of file to delete
DELETE /FileContainers/:containerName/deleteFileByName/:filename
FileContainer.deleteFileByName({
containerName: 'containerName',
filename: 'filename'
});
- containerName - name of container
- filename - name of file to delete
POST /FileContainers/:containerName/upload
- containerName - name of container
GET /FileContainers/download
- fileId - id of file to download
Errors:
- 404 File not found.
GET /FileContainers/:containerName/zip
- containerName - name of container
Errors:
- 404 No files to archive.
GET /FileContainers/downloadZipFiles
- filesId - string with ids of files to download
Errors:
- 404 File not found.
GET /FileContainers/downloadInline/:fileId
- fileId - id of file to download in line
Errors:
- 404 File not found.
GET /FileContainers/getStreamFileId/:fileId
- fileId - id of file to stream
Errors:
- 404 File not found.