mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-11 08:55:23 +03:00
s3-js: got upload working successfully, required CORS * and Headers * and public-read ACL
This commit is contained in:
parent
ff313fb720
commit
ce1f7c957b
@ -25,48 +25,12 @@ export default class S3Client {
|
||||
});
|
||||
}
|
||||
|
||||
createBucket(name) {
|
||||
let params = {
|
||||
Bucket: name,
|
||||
ACL: "public-read"
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.s3) {
|
||||
reject({ error: 'S3 not initialized!' });
|
||||
return;
|
||||
}
|
||||
this.s3.createBucket(params, (error, data) => {
|
||||
if (error) {
|
||||
reject({ error });
|
||||
} else {
|
||||
resolve({ data });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
listBuckets() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.s3) {
|
||||
reject({ error: 'S3 not initialized!' });
|
||||
return;
|
||||
}
|
||||
this.s3.listBuckets({}, (error, data) => {
|
||||
if (error) {
|
||||
reject({ error });
|
||||
} else {
|
||||
resolve({ data });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
upload(bucket, filename, buffer) {
|
||||
let params = {
|
||||
Bucket: bucket,
|
||||
Key: filename,
|
||||
Body: buffer
|
||||
Body: buffer,
|
||||
ACL: 'public-read'
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.s3) {
|
||||
|
Loading…
Reference in New Issue
Block a user