Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-4525

IOS getPicture FileTransfer adds empty enter top of file corrupting image

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.9.0
    • 2.9.0
    • cordova-ios
    • IOS, IPAD 6.x

    Description

      On the ipad I take a photo and transfer that photo to a webservice via phonegap upload.

      The photo appears to have an extra carriage return at the very top of the file when editing in notepad++ image.jpg and also png files produce the same issue.

      Example code -

      upload.js
      navigator.camera.getPicture(
      //success
      function(imageURI) {
      	setTimeout(function() {
      		alert('Picture taken');
      		
      		//Upload Options
      		var options = new FileUploadOptions();
      		//set defaults
      		options.fileKey='primaryFile';
      		options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
      		options.mimeType='image/jpeg'; //or 'image/png'
      		options.chunkedMode = false;
      		
      		//set default form params for service
      		options.params = {
      			dDocAuthor:		'me',
      			dDocTitle:		'Mobile Upload Test', 
      			dDocType:		'Document',
      			dSecurityGroup:		'test',	
      			dDocAccount:		'',		
      			xComments: 		'Mobile Upload'
      		};
      		
      		//Set Auth header
      		var vAuthHeader = Crypto.util.bytesToBase64(Crypto.charenc.Binary.stringToBytes(FB.WebCenterSettings.userName + ':' + FB.WebCenterSettings.password));
      		options.headers = {'Authorization': 'Basic ' + vAuthHeader};
      		
      		var fFileTransfer = new FileTransfer();
      	
      		fFileTransfer.upload(
      			imageURI, 
      			encodeURI(FB.WebCenterSettings[FB.WebCenterSettings.activeServer].ucmPath+'/idcplg?IdcService=CHECKIN_UNIVERSAL&IsJson=1'),
      			//success
      			function(r){
      				alert('[Photo Sucessfully Uploaded]');
      			}, 
      			//fail
      			function(error) {
      				alert('[FAIL]');
      			}, options, true);
      	}, 0);
      	
      	
      //error
      }, function(message) {
      	alert('[Fail]');
      
      //options
      },{ 
      	quality: 		20,
      	destinationType: 	Camera.DestinationType.NATIVE_URI,
      	sourceType: 		Camera.PictureSourceType.CAMERA,
      	encodingType: 		Camera.EncodingType.JPEG,
      	targetWidth: 		650,
      	targetHeight: 		650,
      	saveToPhotoAlbum: 	false
      });
      
      

      Attachments

        Activity

          People

            shazron Shazron Abdullah
            slashemc2k John Sim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: