1.2.0 • Published 8 years ago
out-publish v1.2.0
out-publish
Library to make publishing to S3 easier in node.
Usage
var Publisher = require('out-publish')
var publisher = new Publisher({
accessKeyId: 'aws.s3.accessKeyID',
secretAccessKey: 'aws.s3.secretAccessKey',
bucket: 'your-bucket-name',
region: 'eu-west-1',
timeout: 3000,
proxy: 'http://proxy.com:1234'
});
Install
npm install --save out-publish
Prerequisites
- Node >0.10
- NPM latest
API
fileExists(fileName)
fileName
{String} File to be found. Accepts paths.- return {Promise}
- resolve(true) when file is found
- reject(false) when file is not found
Checks if file exists in S3
download(fileName)
fileName
{String} File to be downloaded. Accepts paths.- return {Promise}
- resolve({String}) contains body of file
- reject({String}) error when downloading file
Downloads a file from S3 and returns back the data
upload(fileName, fileContents, options)
fileName
{String} Name of file to be uploaded.fileContents
{String} File content.options
{Object} File options, such as Content-Type.- return {Promise}
- resolve({Object}) contains information about successfully uploaded file
- reject({String}) error when uploading file
Creates a file and uploads it to S3
url()
- return {String} Gets the absolute url for the S3 bucket.