Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19847] Image won't upload from Android to ArrowDB using API 5.0+

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionDuplicate
Resolution Date2015-11-03T06:48:21.000+0000
Affected Version/sRelease 5.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterRay Belisle
AssigneeEric Merriman
Created2015-11-03T04:39:29.000+0000
Updated2017-03-22T23:08:06.000+0000

Description

If you create a photo object in ArrowDB using an android device, the following error occurs when you try to upload with version 5.0+ of the Titanium API. The SAME CODE running 4.0 - < 5.0 works when uploading an image to Arrow DB. When using 5.0+, I get the following JSON error response after uploading an image: {"success" : false, "error" : true, "code" : 400, "message" : "Failed to upload photo: Cannot serialize an object of class ActionDispatch::Http::UploadedFile in BSON."}

Comments

  1. Ray Belisle 2015-11-03

    Code is as follows for a reproducible test case. Fails when I compile using 5.02GA but works when I use 4.11GA Index.xml Index.js var args = arguments[0] || {}; var Cloud = require('ti.cloud'); var user = null; function init() { Cloud.Users.login({ login : $.name.value, password : $.pass.value }, function(e) { if (e.success) { user = e.users[0]; alert('Success:\n' + 'id: ' + user.id + '\n' + 'sessionId: ' + Cloud.sessionId + '\n' + 'first name: ' + user.first_name + '\n' + 'last name: ' + user.last_name); alert(JSON.stringify(user)); } else { alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } }); } function captureImage() { var dlg = Titanium.UI.createAlertDialog({ message : 'Please Select', buttonNames : ['Take Photo', 'Photo Library'] }); dlg.addEventListener('click', function(ev) { if (ev.index == 0) { Ti.Media.showCamera({ showControls : true, mediaTypes : Ti.Media.MEDIA_TYPE_PHOTO, autohide : true, allowEditing : false, success : function(event) { var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'test.jpg'); f.write(event.media); $.myimage.image = f.nativePath; }, cancel : function() { }, error : function(error) { } }); } else if (ev.index == 1) {// clicked "No" Ti.Media.openPhotoGallery({ mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO], success : function(event) { var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'test.jpg'); f.write(event.media); $.myimage.image = f.nativePath; }, cancel : function() { }, error : function(error) { } }); } }); dlg.show(); } function createPhoto() { Cloud.Photos.create({ photo : Titanium.Filesystem.getFile($.myimage.image), user_id : user.id }, function(e) { if (e.success) { var photo = e.photos[0]; alert('Success:\n' + 'id: ' + photo.id + '\n' + 'filename: ' + photo.filename + '\n' + 'size: ' + photo.size, 'updated_at: ' + photo.updated_at); } else { alert(JSON.stringify(e)); } }); }
  2. Ashraf Abu 2015-11-03

    [~raybelisle] Could you try running this on terminal to get an updated SDK appc ti sdk install -d -b 5_0_X Which contains 5.0.3 with the fixes. Let me know if it works for you.
  3. Ray Belisle 2015-11-03

    Yes, that works. Any idea when 5.03GA will be available? I would love to update to the latest SDK but would want it to be a tested version
  4. Ashraf Abu 2015-11-03

    5.0.3 is essentially 5.0.2.GA with the fixes particular to this issue. Right now what's lined up is 5.1.0.GA. https://community.appcelerator.com/topic/3897/sdk-5-1-0-beta-and-studio-4-4-0-beta-now-available SDK 5.1.0.Beta is now available. Next would be 5.1.0.GA.
  5. Ashraf Abu 2015-11-03

    Resolving this issue as Duplicate of TIMOB-19784
  6. Lee Morris 2017-03-22

    Closing ticket as duplicate as the relevant ticket is linked above.

JSON Source