This repo is an updated version of https://bitbucket.org/javidgon/solid-bucket/src/master/ for wasabi deployments only.
npm install wasabi-s3This repo is an updated version of https://bitbucket.org/javidgon/solid-bucket/src/master/ for wasabi deployments only.
javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
`
3. Universal API
$3
#### 3.1.1 Definition
`javascript
provider.createBucket(bucketName); // returns a Promise
`
#### 3.1.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
provider
.createBucket(bucketName)
.then((resp) => {
if (resp.status === 201) {
console.log(resp.message);
// Output: Bucket "example" was created successfully
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.2.1 Definition
`javascript
provider.deleteBucket(bucketName); // returns a Promise
`
#### 3.2.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
provider
.deleteBucket(bucketName)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: Bucket "example" was deleted successfully
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.3.1 Definition
`javascript
provider.uploadFile(bucketName, filePath); // returns a Promise
`
#### 3.3.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
let filePath = '/tmp/file.bin';
provider
.uploadFile(bucketName, filePath)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: Bucket "example" was deleted successfully
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.4.1 Definition
`javascript
provider.deleteBucket(bucketName, remoteFilename downloadedFilePath) // returns a Promise
`
#### 3.4.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
let remoteFilename = 'file.bin';
let downloadedFilePath = '/tmp';
provider
.downloadFile(bucketName, remoteFilename, downloadedFilePath)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: Bucket "example" was deleted successfully
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.5.1 Definition
`javascript
provider.createFileFromText(bucketName, remoteFilename, text); // returns a Promise
`
#### 3.5.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
let remoteFilename = 'my_remote_object.txt';
let text = 'This is a text that I would like to upload';
provider
.createFileFromText(bucketName, remoteFilename, text)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: Object "example.txt" was saved successfully in bucket "example"
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.6.1 Definition
`javascript
provider.deleteFile(bucketName, remoteFilename); // returns a Promise
`
#### 3.6.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
let remoteFilename = 'my_remote_object.txt';
provider
.deleteFile(bucketName, remoteFilename)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: Object "example.txt" was deleted successfully from bucket "example"
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.7.1 Definition
`javascript
provider.readFile(bucketName, remoteFilename); // returns a Promise
`
#### 3.7.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
let remoteFilename = 'my_remote_object.txt';
provider
.readFile(bucketName, remoteFilename)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: Object "example.txt" was fetched successfully from bucket "example"
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
`
$3
#### 3.8.1 Definition
`javascript
provider.getListOfFiles(bucketName); // returns a Promise
`
#### 3.8.2 Full Example
`javascript
const WasabiS3 = require('wasabi-s3');
let provider = new WasabiS3('wasabi', {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
});
let bucketName = 'example';
provider
.getListOfFiles(bucketName)
.then((resp) => {
if (resp.status === 200) {
console.log(resp.message);
// Output: The list of objects was fetched successfully from bucket "example"
}
})
.catch((resp) => {
if (resp.status === 400) {
console.log(resp.message);
// Output: Some error coming from the provider...
}
});
``