By abelchunqhai
I’m using DO space for the first time to upload images and documents. I used multer and multer-s3 to upload multiple images. The function works fine and show successful without error. But DO space doesn’t show any updates. The files doesn’t upload to the DO space. I tried URL but no such key.
I set my DO Space:
const bucket = 'MY_DO_UNIQUE_NAME';
const spacesEndpoint = new AWS.Endpoint('sgp1.digitaloceanspaces.com');
const s3 = new AWS.S3({
endpoint: spacesEndpoint,
accessKeyId: process.env.DO_ACCESS_KEY,
secretAccessKey: process.env.DO_SECRET_KEY
});
const upload = multer({
storage: multerS3({
s3:s3,
bucket: bucket,
acl: 'public-read',
key: function (request, file, cb) {
console.log(file);
cb(null, file.originalname);
}
}),
}).array('file', 100);
upload(req, res, function (error, file, data) {
if (error) {
console.log(error);
return response.redirect("/error");
}
console.log('File uploaded successfully.');
});
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello! I’m having a similar problem but in my case I get the return above but my files are unreadable in spaces. I use the AWS api.
Greetings!
I’m sorry about the trouble this is causing for you. My concern is that perhaps your code is not putting out an error, but that this may not be a clear indication that our server has actually accepted the upload. Are you able to fully output the response from our server when you upload the object? Here’s an example of what a successful response might look like to a PUT:
HTTP/1.1 200 OK
Date: Mon, 10 Jul 2017 19:46:06 GMT
x-amz-request-id: tx0000000000000027bd57c-005963d97e-1268c-nyc3a
Content-Length: 0
Accept-Ranges: bytes
Last-Modified: Mon, 10 Jul 2017 19:05:09 GMT
Etag: "fb08934ef619f205f272b0adfd6c018c"
Connection: close
Jarland
Hi,
Same problem! Impossible upload a file with DO Space., but same code works on my AWS S3.
Help please…
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.