Please need help with csv to blob to pass to AWS translate Javascript

Kdes

Well-Known Member
Joined
Aug 21, 2007
Messages
158
Reaction score
3
Good Day

Im a complete beginner with development and something i am teaching my self.
I am playing around with AWS Translate.

Using the AWS javascript SDK within browser.(ie loading the sdk.js).

AWS Translate allows you to upload CSV files containing, custom terminology for the translation.
It requires that you pass the CSV as a blob.

Using javascript or jquery, how do i create an upload of the csv input that adds to a blob?

function UploadTerm() {

var blobvar = // how do i get a file csv as a blob?

var params = {
MergeStrategy: 'OVERWRITE',
Name: 'test',
TerminologyData: {
File: blobvar,
Format: 'CSV'
},
Description: 'this is a test',
};
translate.importTerminology(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
}


Thank you.
 
Last edited:
Not what you are asking for but for what it is worth: it might be easier to do this as a lambda function triggered from S3.

That way you can use python to wrangle that data, IIRC you also have to batch the data you send as the limit for the service is a few bytes. This might be Comprehend and not Translate, so please take with a pinch of salt. Memory is a bit hazy.
 

readAsDataURL(file) method is "most probably" what you're after, knowing AWS.

You're uploading from clientside? Otherwise just use node to convert the readFile buffer for you.

And make sure your csv is formatted *exactly* like the aws examples.

If you are capable, Write a preflight check function before sending the data to aws. It will save you 3am phone calls.

No funky ascii or anything other than utf8 / utf16 if your using high ascii ranges. Also careful of Cyrillic and Traditional Chinese vs Modern Chinese, these are a pain.
 
Top
Sign up to the MyBroadband newsletter
X