s3-fs
Easy access to the AWS S3 files
interface fs
file
is a URL chema such as s3://my.buket/my/path/file.ext
fs.createReadStream(file)
Create and returns a stream for reading
const fs = ; const file = 's3://buket/file.txt' fs;
fs.createWriteStream(file)
Create and returns a stream for writing. There is a callback called when the file has been written
var fs = ; const file = 's3://buket/file.txt' const writeStream = fs; writeStream;writeStream;
fs.unlink(file)
remove a s3 file. There is a callback called when the file has been removed
var fs = ; const file = 's3://buket/file.txt' fs;
fs.readdir(dir, [options,] callback)
Return the name of files and folders ({String}) in the passed path (path must finish with '/'). If the returned name finish with '/' means it is a "folder"
Options
- If passed
{ flat: true }
as options it returns all the tree under the directory, not only the first level
Callback
- error or null if no error
- array of documents or empty array if o documents found
- next functon to be called (next()) if there are more results, or `null if no more results
var fs = ; const dir = 's3://buket/mydir/' fs;
fs.readFile(file[, encoding], callback)
Return the content of the file ({Buffer}) if not encoding is specified. If encoding is specified, it is applied to the resulting buffer
var fs = ; const file = 's3://buket/file.txt' fs; fs;
fs.writeFile(file, data[, encoding], callback)
Write the data into the file. If encoding is specified, it is applied
var fs = ; const file = 's3://buket/file.txt' fs; fs