Start a new topic
Answered

Titanium image upload

Hi everyone,

I was using Kinvey v1 within my Titanium app and when uploading my image with this code:

 

var image = evt.media.imageAsResized(300,300);
var promise = Kinvey.File.upload(image, null, {
   public: true
});
promise.then(function(e) {
	var promise = Kinvey.File.stream(e._id, {
	 	success: function(file) {
			var imageurl = file._downloadURL;
	 	},error: function(e){
			console.log("error uploading file...");
	 	}
	});
}, function(error) {
	console.log(error);
});

 everything just worked fine.

Now I'm trying to follow the new V3 approach and it doesn't work. Also, seems that the example on Titanium's documentation is some sort of Web JS instead of Titanium specific guide.


This is my v3 code:

 

var image = evt.media.imageAsResized(300,300);
   var metadata = {
      public: true
   };
   var promise = Kinvey.Files.upload(image,metadata)
   .then(function(file) {
      console.log(" *** SUCCESS UPLOADING IMAGE: " + JSON.stringify(file));
   })
   .catch(function(error) {
      console.log(" *** error on image upload: " + JSON.stringify(error));
   });

 and this is the error message it gives me:

 

{"debug":"","code":400,"line":34537,"column":32,"sourceURL":"/kinvey-titanium-sdk-3.4.4.js"}

 Just to make it clear, "evt.media" is the resulted image/blob from my camera/photo gallery from device (iOS)

I have also tried to save the image as an jpg file on device's memory but it also doesn't seem to work. The image is been uploaded but when I try to check its URL the browser doesn't understand it as an image.

Can you give me some idea on how to proceed? Maybe a Titanium-specific documentation on image uploading would be nicer =)


Thanks!


Best Answer
Carlos,

Are you still facing this issue? I reviewed recent logs and didn't find any errors representing image upload problems.

Thanks,
Pranav
Kinvey

 


Hello Carlos,


Thank you for reporting this. We will investigate and get back with you with recommendations as soon as possible.


The 400 error indicates that the request being sent is not formed correctly. Unfortunately, I cannot see the actual query in our logs since it has been cleared. Can you please send the filename of the file you are trying to upload? I also cannot find a file named "evt.media" in our logs.


Finally if you could send the actual query that you are using to sent in the request including the data in the query, that would be very helpful in our investigation.


We look forward to hearing back from you.


Regards,


Billy Gee

Answer
Carlos,

Are you still facing this issue? I reviewed recent logs and didn't find any errors representing image upload problems.

Thanks,
Pranav
Kinvey

 

Login or Signup to post a comment