Copy link to clipboard
Copied
Hello,
I would like to upload media file in s3 using Premiere Pro. extension.
For that, I have created one Premiere Pro. extension.
I have used below code to upload media.
uploadOnS3 = function (data) {
console.log('uploadOnS3 called');
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "XXX",
secretAccessKey: "XXX"
});
var s3 = new AWS.S3();
var bucketName = 'flex-qa3';
var keyName = 'AA.mp4';
var params = {Bucket: bucketName, Key: keyName, Body: data};
var options = {partSize: 10 * 1024 * 1024, queueSize: 1};
s3.upload(params, options, function(err, data) {
console.log(err, data);
});
}
uploadFile = function () {
console.log('uploadFile called');
var fsModule = 'fs';
var fs = require(fsModule);
// First I want to read the file
fs.readFile("D:/Projects/AA.mp4", function read(err, data) {
uploadOnS3(data);
});
}
uploadFile();
I have added node js support in manifest.xml file in extension and I am using 'aws-sdk' for s3 upload.
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
I can upload this file successfully on s3 but when I download this file and open with media player.
It couldn't play and it is corrupted.
Same code when I run with directly by node application without Premiere Pro. then it works and media file doesn't corrupt.
Same way when I download the file using 'FS' module in premiere pro then file corrupted and couldn't open in media player.
The Same code works outside the Premiere Pro. well.
Could you provide the proper way to upload and download media file?
Do I need to use any encoding type?
Are there any specific changes in Premiere Pro related to Buffer API and read/write related API?
Premier Pro. Version: 11.0
Thanks @Nirav, that explains your problem. There could be few improvements to your code, one of them would be having error check during readFile. Please refer to javascript - Get data from fs.readFile - Stack Overflow
Copy link to clipboard
Copied
Moved to Premiere Pro SDK forum.
Copy link to clipboard
Copied
Hi,
this is looking similar to this thread, only the other way round: https://forums.adobe.com/thread/2340929 .
Do you happen to know if the uploaded file is already corrupt, or only the (re-)downloaded one?
Copy link to clipboard
Copied
No, its play in media player very well before upload but when I download uploaded file, that was corrupted
Copy link to clipboard
Copied
My question was if you can verify the uploaded file on AWS is intact. So on the AWS, after uploading, before downloading.
Copy link to clipboard
Copied
That file corrupted cause the actual size of a file is 3.59MB but when I saw on s3 it was 4.86MB. So the problem is in uploading the file from the Premiere Pro. as I had already told that same code works well from outside the panel using directly node js.
Copy link to clipboard
Copied
Can anyone please help for this issue?
Copy link to clipboard
Copied
You're asking for help with Node.js upload questions, in a forum about Premiere Pro's APIs.
A place to start = does your uploading function behave differently, or give different results, when running within a panel, instead of a web browser?
Copy link to clipboard
Copied
Hey Bruce. Nirav did indeed run the code outside the PrPro panel and it worked fine, which is what caused him to raise the question here...
Copy link to clipboard
Copied
I've asked the CEP team to respond.
Copy link to clipboard
Copied
@Nirav, Can you please record md5 values before uploading the file? and after downloading the file?
Copy link to clipboard
Copied
The file size is different so both md5 should be different.
Copy link to clipboard
Copied
Thanks @Nirav, that explains your problem. There could be few improvements to your code, one of them would be having error check during readFile. Please refer to javascript - Get data from fs.readFile - Stack Overflow
Copy link to clipboard
Copied
I haven't got any error while readFile.