Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
phonegap to amazon S3 uploaded image is corrupted

I am using javascript from phonegap to upload an image from ios gallery. the image upload goes fine but the image is corrupted.

Here is the code:

<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"></script>
        <script type="text/javascript">
            app.initialize();
            var imgData = null;

            function uploadToS3(imageData) {
                  var imgData = getImgData(imageData); 
                  var key = 'SOME_IMAGE_NAME.jpg'; 

                  AWS.config.update({accessKeyId: 'XXX', secretAccessKey: 'XXX', region:'us-west-1'});
                  var bucket = new AWS.S3({params:{Bucket: 'mybucket'}});

                  var params = {
                    Key: key,
                    Body: imageData,
                    ACL: 'public-read',
                    ContentType: 'image/jpeg'
                  };

                  bucket.upload(params, function(err, data) {
                          alert(data.Location);  
                  });
                }


            function getImage() {
                      navigator.camera.getPicture(onSuccess, onFailure, { navigator.camera.getPicture(onSuccess, onFailure, {quality: 25,
              destinationType: navigator.camera.DestinationType.DATA_URL,
              sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
                 });


                 function onSuccess(imageURI) {
                    var imgData = "data:image/jpeg;base64," + imageURI;
                    uploadToS3(imgData);
                }

                function onFailure(message) {
                    alert("Get image failed: " + message);
                }
        }
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!