I would like to download a file from S3 in Zapier and use it (as file exists but not shown) in the rest of a Zap. Strangely the S3 integration doesnt offer this (although you can do this in Box, Drive etc).
I guess we will need to use Code by Zapier and I have this basic JS - but I think I need to specify region and not sure how to link the output into Zap?
var AWS = require('aws-sdk');
AWS.config.update(
{
accessKeyId: ".. your key ..",
secretAccessKey: ".. your secret key ..",
}
);
var s3 = new AWS.S3();
s3.getObject(
{ Bucket: "my-bucket", Key: "my-picture.jpg" },
function (error, data) {
if (error != null) {
alert("Failed to retrieve an object: " + error);
} else {
alert("Loaded " + data.ContentLength + " bytes");
// do something with data.Body
}
}
);
output = need to put my file here!!
I'd appreciate any pointers - I am surprised this has not been asked before - I hope it doesnt mean that I have missed something very obvious!
Here is example to get json document from s3
var AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: ".. your key ..",
secretAccessKey: ".. your secret key ..",
region: "region",
});
var s3params = {
Bucket: "bucket",
Key: "key",
};
s3.getObject(s3params, function (err, data) {
if (err) {
console.error(err.message);
} else {
let jsonString = data.Body.toString();
let result = JSON.parse(jsonString);
return result;
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.