I am trying to upload a file to S3 using apps script.
I have been trying to use https://github.com/viuinsight/google-apps-script-for-aws
S3.init();
S3.putObject("bucket123", 'Tacofile.txt', content, 'ca-central-1')
- I retrieve a file from Google Workspace, where 'Tacofile' is a .txt file
- The file successfully loads to S3
The file, however, somehow gets converted to json? How to keep the file as a csv or is there a way to specify the MIME type somewhere before the upload?
thanks in advance
CB
CodePudding user response:
Yes use File.getBlob() S3.putObject("bucket123", 'Tacofile.txt', content.getBlob(), 'ca-central-1')
CodePudding user response:
@theWizEd thanks for pointing me in the right direction! I think I got this to work. I changed my source data so my download was done using:
object = DriveApp.getFileById(file_id).getBlob().getDataAsString();
i changed the section in line 106 below:
if (notBlob) {
object = Utilities.newBlob(JSON.stringify(object), "application/json");
object.setName(objectName);
}
var content = object.getDataAsString();
var contentType = object.getContentType();
var contentMD5 = getContentMD5(content);
to the following
if (notBlob) {
//object = Utilities.newBlob(JSON.stringify(object), "application/json");
//object.setName(objectName);
}
var content = object;
var contentType = MimeType.PLAIN_TEXT
var contentMD5 = getContentMD5(content);