You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Clint Ghosn (JIRA)" <ji...@apache.org> on 2015/08/06 15:29:04 UTC

[jira] [Commented] (CB-4525) IOS getPicture FileTransfer adds empty enter top of file corrupting image

    [ https://issues.apache.org/jira/browse/CB-4525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14660001#comment-14660001 ] 

Clint Ghosn commented on CB-4525:
---------------------------------

Hi John Sim, 

I am also having this problem, on the top of the corrupted file there is a string being added:

tent-Length: 86767

This seems like the content-length header.
I temporarily solved this issue by modifying CDVFileTransfer.m and commenting out all the postBeforeBody commands. After this, the image is being uploaded fine and can be opened using Preview (mac).

However, because of this I encountered another issue: the headers are not being sent to the server anymore.

Any tips on how to solve this? If on the server side, what could possibly cause this issue?

> IOS getPicture FileTransfer adds empty enter top of file corrupting image
> -------------------------------------------------------------------------
>
>                 Key: CB-4525
>                 URL: https://issues.apache.org/jira/browse/CB-4525
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.9.0
>         Environment: IOS, IPAD 6.x
>            Reporter: John Sim
>            Assignee: Shazron Abdullah
>              Labels: test
>             Fix For: 2.9.0
>
>
> 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 - 
> {code:JavaScript|title=upload.js|borderStyle=solid}
> 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
> });
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org