jeudi 28 mai 2015

How do I upload a zip file to Amazon S3 using Javascript (Angular framework)?

Using the following code:

params = {
    Bucket: 'bucket.com',
    Key: zipPath
    },
s3 = new AWS.S3();
params.Body = zipFile;
s3.putObject(params, function(err, data) {
    if (err) {
        logger.info('Upload error: ' + err);
    } else {
        logger.info('Uploaded: ' + String(data));
    }
});

When I change the body contents to a string (i.e 'Hello'), it will upload perfectly fine. However, when I try to attach a zip file, it is not working. Any ideas? I am really new to uploading files and can't seem to find any answers online.

Error that I get: Upload error: Error: Cannot determine length of [object Object]

EDIT: the zip contains images.




Aucun commentaire:

Enregistrer un commentaire