3 Replies Latest reply on Jun 1, 2017 12:23 PM by sberic

    AWS S3: Download media file get corrupted

    meett9325076 Level 1

      Hi All,

       

      I am trying to download media file (image or video) from AWS S3 using nodejsaws-sdk module. The file is downloaded but I couldn't open as it looks corrupted. Also noted that file size is not same as source file. Refer below code:

       

       

      var AWS = require('aws-sdk');
      
      var options = {
      accessKeyId: "XXX",
      secretAccessKey: "XXX"
      };
      var s3 = new AWS.S3(options);
      
      var bucketName = 'test-bucket';
      var keyName = 'test.jpg';
      var params = {Bucket: bucketName, Key: keyName};
      
      var fsModule = "fs";
      var fs = require(fsModule);
      
      // This requires when running this code in panel
      AWS.util.stream = require('stream');
      
      var writeStream = fs.createWriteStream('D:/test.jpg');
      var readStream = s3.getObject(params).createReadStream();
      
      readStream.pipe(writeStream);
      

       

      I have added aws-sdk node module in my extension folder.

       

      Note:
      (1) I can download and open txt file without any issue
      (2) If I run this code outside panel context (run in local nodejs server) it works for all type of files including text and media!!

       

       


      Premiere Pro version: 9.0.0
      Extension Type: Panel

       


      Thanks & Regards,
      Meet Tank