Hi,
The application works on android device version 5.0, but fails in 4.2. The problem is sending blob data appended in formdata. The code is as follows:
problemData = new FormData();
problemData.append('problem', $scope.problem['id']);
problemData.append('description', $scope.imgcomment);
var blobdata = dataURItoBlob("data:image/jpeg;base64,"+$scope.lastImage);
problemData.append('image', blobdata, 'problem.jpg');
$http.post(post_url, problemData, {transformRequest: angular.identity, headers: {'Content-Type': undefined}})
.success( function (data){
$scope.lastImage = false;
})
.error(function(e, s, h) {
$scope.lastImage = false;
});
as I’ve written above this code works with android 5.0 but fails with 4.2.
The dataURItoBlob function transforms uridata to blob and I’ve checked it’s working properly on both devices.
The data is sent to an api-server and always receives 400 error code. I have redirected the post url to a php script and this is the image data received:
array (
'image' =>
array (
'name' => 'Blob97524901ba8f43d2b0677909c93a5dce',
'type' => 'image/jpeg',
'tmp_name' => '/tmp/phpf11B1i',
'error' => 0,
'size' => 0,
),
)
Size is 0 and the name is not problem.jpg as was specified in code.
Could be append function on FormData is working different? Or the problem must be in http.post?