Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
adonis-filesystem
Advanced tools
This package allows uploading files to local fs, cloud storage, or another provider easy.
This package allows uploading files to local fs, cloud storage, or another provider easy.
NOTE This pacakge is currently in development. While the public API will be pretty stable, new features, connectors, and internal plumbing will change over time until v1.0.0 is reached
To install this addon:
npm install --save adonis-filesystem
Then update the bootstrap/app.js
:
providers
array add: adonis-filesystem/providers/FilesystemProvider
File: 'AdonisFilesystem/Filesystem'
to the aliases
objectsAdd named config/filesystems.js
with the following:
'use strict'
const Env = use('Env')
const Helpers = use('Helpers')
module.exports = {
default: 'public',
public: {
driver: 'local',
root: Helpers.publicPath('uploads'),
options: {
encoding: 'utf8'
}
},
protected: {
driver: 'local',
root: Helpers.storagePath('app'),
options: {
encoding: 'utf8'
}
}
}
This will setup file connections to create files in public/uplodads
using the public
connection, and storage/app
for the protected
connections.
Because the default use case is for image uploading, the public
connection is set as a default, though this can be changed with the default
parameter.
To write to files use the put
method on a Filesystem connection:
const File = use('File') // or use('AdonisFilesystem/Filesystem') if you did not install the alias
yield File.put('app.js', 'This is the contents of my file')
This will use the default connection to write a file named app.js
with the text content 'This is the contents of my file'
.
The point of the Filesystem connection is that consuming applications do not worry about if files are local or on a cloud provider.
To read to files use the get
method on a Filesystem connection:
const File = use('File') // or use('AdonisFilesystem/Filesystem') if you did not install the alias
yield File.get('app.js')
This will use the default connection to read a file named app.js
.
Uploading files can be a chore, by using the upload
method, the Filesystem package will use streams to upload a file from request.file
to the final upload destination:
const File = use('File') // or use('AdonisFilesystem/Filesystem') if you did not install the alias
const avatar = request.file('avatar', {
maxSize: '2mb',
allowedExtensions: ['jpg', 'png', 'jpeg']
})
yield File.upload(avatar.clientName(), avatar)
To use other connectors, use the connection
method on the file instance.
This will allow you to use a different connection than the default for a single file transaction:
const File = use('File') // or use('AdonisFilesystem/Filesystem') if you did not install the alias
yield File.connection('protected').put('secret.json', 'The silence will fall when the question is asked.')
This package is distributed under the MIT license.
FAQs
This package allows uploading files to local fs, cloud storage, or another provider easy.
The npm package adonis-filesystem receives a total of 3 weekly downloads. As such, adonis-filesystem popularity was classified as not popular.
We found that adonis-filesystem demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.