loopback-component-storage-mongo-gridfs-ssrx

1.0.3 • Public • Published

loopback-component-storage-mongo-gridfs

Uses mongoDB GridFS to manage binary contents of your loopback application.

Inspired by

Behaviors

  • 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.

Installation

npm install --save loopback-component-storage-mongo-gridfs

Datasource

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

API

List containers

GET /FileContainers
FileContainer.getContainers();

Elimina toso los ficheros que cumplen con la condición

DELETE /FileContainers/delete/:where
FileContainer.delete({
  where: 'where'
});

Delete container

DELETE /FileContainers/:containerName
FileContainer.deleteContainer({
  containerName: 'containerName',
  fileId: 'fileId'
});
  • containerName - name of container to delete

List files in container

GET /FileContainers/:containerName/files
FileContainer.getFiles({
  containerName: 'containerName'
});
  • containerName - name of container

Errors:

  • 404 File not found.

Get file information

GET /FileContainers/:containerName/files/:fileId
FileContainer.getFile({
  containerName: 'containerName',
  fileId: 'fileId'
});
  • containerName - name of container
  • fileId - id of file

Get file information by name

GET /FileContainers/:containerName/getFileByName/:filename
FileContainer.getFileByName({
  containerName: 'containerName',
  filename: 'filename'
});
  • containerName - name of container
  • filename - name of file

Delete file

DELETE /FileContainers/:containerName/files/:fileId
FileContainer.deleteFile({
  containerName: 'containerName',
  fileId: 'fileId'
});
  • containerName - name of container
  • fileId - id of file to delete

Delete file by fileId

DELETE /FileContainers/files/:fileId
FileContainer.deleteFileByFileId({
  fileId: 'fileId'
});
  • fileId - id of file to delete

Delete file by filename

DELETE /FileContainers/:containerName/deleteFileByName/:filename
FileContainer.deleteFileByName({
  containerName: 'containerName',
  filename: 'filename'
});
  • containerName - name of container
  • filename - name of file to delete

Upload files

POST /FileContainers/:containerName/upload
  • containerName - name of container

Download file

GET /FileContainers/download
  • fileId - id of file to download

Errors:

  • 404 File not found.

Download container as zip file

GET /FileContainers/:containerName/zip
  • containerName - name of container

Errors:

  • 404 No files to archive.

Download files zip

GET /FileContainers/downloadZipFiles
  • filesId - string with ids of files to download

Errors:

  • 404 File not found.

Download file inline

GET /FileContainers/downloadInline/:fileId
  • fileId - id of file to download in line

Errors:

  • 404 File not found.

Get steam file by FileId

GET /FileContainers/getStreamFileId/:fileId
  • fileId - id of file to stream

Errors:

  • 404 File not found.

Readme

Keywords

Package Sidebar

Install

npm i loopback-component-storage-mongo-gridfs-ssrx

Weekly Downloads

1

Version

1.0.3

License

none

Unpacked Size

33.1 kB

Total Files

7

Last publish

Collaborators

  • palrajesh