Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1381] Cloud.Users.update of photo returns 'failed to upload photo: undefined method `destroy' for nil:NilClass'

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNeeds more info
Resolution Date2015-09-30T03:54:28.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterKeylo E.
AssigneeShak Hossain
Created2015-06-16T02:10:34.000+0000
Updated2016-03-08T07:37:48.000+0000

Description

Steps to Reproduce

(All tests done on same user The standard Cloud.Users.update method of updating a user's photo was confirmed, installed the app on ipad and confirmed again. Continued testing from laptop for MobileWeb portion of the app with this, http://developer.appcelerator.com/question/182699/cloudusersupdate-photo-returns-success-but-no-change-wrong-media-type , resulted in error "Failed to upload photo: Failed to indentify photo file" or depending upon my sent data, silently failed when changing reader.readAsDataURL() to reader.readAsBinaryString() and various methods from this reference http://www.html5rocks.com/en/tutorials/file/dndfiles until I started getting consistent error responses 'failed to upload photo: undefined method destroy' for nil:NilClass' I returned to the device to test with working, unchanged installed app and got the same error same response, 'failed to upload photo: undefined method destroy' for nil:NilClass' Tested from dashboard, same error response (All tests done on same user)

Actual Result

Existing user's photo deleted but not replaced. Unable to update

Expected Result

successful update

Attachments

FileDateSize
.log2015-06-16T02:11:02.000+00006211688
diagnostic903946955486080361.log2015-06-16T02:11:06.000+000078861

Comments

  1. Radamantis Torres-Lechuga 2015-06-17

    [~keylo] you mind sharing a test case with us? So far we can not reproduce this issue Thanks
  2. Keylo E. 2015-06-17

    Everything is in the link I posted http://developer.appcelerator.com/question/182699/cloudusersupdate-photo-returns-success-but-no-change-wrong-media-type and description above. Started with a working Cloud.Users.update method, which you can reproduce without my help, then did what the link states, changing reader.readAsDataURL() to reader.readAsBinaryString(), reader.readAsText(), reader.readAsArrayBuffer(), sometimes passing update the result.data as well as the result until it breaks. It might have taken 10 or 20 tries before shutting down. I may have also tried passing handleFileSelect's evt[0] (file) directly from the without passing it through the reader. Returned to the working update method to confirm
  3. Radamantis Torres-Lechuga 2015-06-22

    [~morahman] Did you try from dashboard?
  4. Keylo E. 2015-06-22

    "Tested from dashboard, same error response"
  5. Motiur Rahman 2015-06-26

    [~keylo] we also have tested from the dashboard and it works, if it shows error it may cause of large file so just try it again. And this test case User photo is updated properly. So first check your webView chooseing image getting the titanium code.
       var win = Ti.UI.createWindow({
       	backgroundColor : '#fff'
       });
        
       // Create a Button.
       var Update_Photo = Ti.UI.createButton({
       	title : 'Update_Photo',
       	height : Ti.UI.SIZE,
       	width : Ti.UI.SIZE,
       	top : 20,
        
       });
        
       // Add to the parent view.
       win.add(Update_Photo);
        
       var Cloud = require("ti.cloud");
        
       Cloud.Users.create({
       	email : 'test@mycompany.com',
       	first_name : 'test_firstname',
       	last_name : 'test_lastname',
       	password : 'test_password',
       	password_confirmation : 'test_password',
       	photo : Titanium.Filesystem.getFile('KS_nav_ui.png')
       }, function(e) {
       	if (e.success) {
       		var 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);
       	} else {
       		alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
       	}
       });
        
       function update_photo() {
       	Cloud.Users.update({
       		email : 'test@mycompany.com',
       		first_name : 'test_firstname',
       		last_name : 'test_lastname',
       		photo : Titanium.Filesystem.getFile('KS_nav_views.png'),
       		custom_fields : {
       			favorite_color : 'blue',
       			age : 25
       		}
       	}, function(e) {
       		if (e.success) {
       			var user = e.users[0];
       			alert('Success:\n' + 'id: ' + user.id + '\n' + 'first name: ' + user.first_name + '\n' + 'last name: ' + user.last_name);
       		} else {
       			alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
       		}
       	});
       }
        
       // Listen for click events.
       Update_Photo.addEventListener('click', function() {
       	update_photo();
       });
        
       win.open();
        
       
    Thanks.
  6. Keylo E. 2015-06-26

    Titanium.Filesystem.getFile('KS_nav_views.png') would not work in the scenario described as the need was to browse to a file in a MobileWeb app, thus the WebView HTML solution, which broke the system.
  7. Radamantis Torres-Lechuga 2015-06-26

    [~keylo] can you please attach a runnable test case that reproduces the issue? So far we can not replicate the issue

JSON Source