[TIMOB-19784] Android: Cloud Files Create Error "Invalid Name"
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-10-27T20:02:45.000+0000 |
| Affected Version/s | Release 5.0.1, Release 5.0.2, Release 5.0.0 |
| Fix Version/s | Release 5.1.0, Release 5.0.3, Release 5.2.0 |
| Components | Android |
| Labels | android |
| Reporter | Ashraf Abu |
| Assignee | Ashraf Abu |
| Created | 2015-10-26T03:52:11.000+0000 |
| Updated | 2015-11-20T04:32:16.000+0000 |
Description
This is working correctly in SDK 4.1.0.GA.
Using 5.0.2.GA and the code below:
Cloud.Files.create({
name: 'my_file_1234567',
file: theFile
}, function (e) {
if (e.success) {
// do stuff here
} else {
Ti.API.info(JSON.stringify(e));
}
});
Produces error:-
10-25 23:47:33.283 29748 29833 E TiHTTPClient: (TiHttpClient-3) [85523,88494] HTTP Error (java.io.IOException): 400 : Bad Request
10-25 23:47:33.283 29748 29833 E TiHTTPClient: java.io.IOException: 400 : Bad Request
10-25 23:47:33.283 29748 29833 E TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1213)
10-25 23:47:33.283 29748 29833 E TiHTTPClient: at java.lang.Thread.run(Thread.java:818)
10-25 23:47:33.285 29748 29761 I TiAPI : {"success":false,"error":true,"code":400,"message":"Invalid name"}
10-25 23:47:33.285 29748 29761 I ALERT : (KrollRuntimeThread) [3,88497] {"success":false,"error":true,"code":400,"message":"Invalid name"}
Ticket created based on information from: https://community.appcelerator.com/topic/3825/cloud-files-create-error-invalid-name/
Place file in
resources/mytestfile.txtCode to reproduce error:-// this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000'); var win = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var button = Titanium.UI.createButton({ title:'Press to Upload' }); win.add(button); var ACS = require('ti.cloud'); button.addEventListener('click', function(e) { ACS.Files.create({ name: 'mytestfile.txt', file: Ti.Filesystem.getFile("mytestfile.txt") }, function (e) { if (e.success) { alert("success"); } else { Ti.API.info(JSON.stringify(e)); alert(JSON.stringify(e)); } }); }); win.open(); // added during app creation. this will automatically login to // ACS for your application and then fire an event (see below) // when connected or errored. if you do not use ACS in your // application as a client, you should remove this block (function(){ var env = Ti.App.deployType.toLowerCase() === 'production' ? 'production' : 'development', username = Ti.App.Properties.getString('acs-username-'+env), password = Ti.App.Properties.getString('acs-password-'+env); // if not configured, just return if (!env || !username || !password) { return; } /** * Appcelerator Cloud (ACS) Admin User Login Logic * * fires login.success with the user as argument on success * fires login.failed with the result as argument on error */ ACS.Users.login({ login:username, password:password, }, function(result){ if (env==='development') { Ti.API.info('ACS Login Results for environment'+env+':'); Ti.API.info(result); } else { alert("prod"); } if (result && result.success && result.users && result.users.length){ Ti.App.fireEvent('login.success',result.users[0],env); } else { Ti.App.fireEvent('login.failed',result,env); } }); })();Master PR: https://github.com/appcelerator/titanium_mobile/pull/7350 5_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/7351 5_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/7352
Verified the fix. We do not see any error & it returns a success. Checked with the code in the PR. Closing. Environment: Appc Studio : 4.4.0.201510231805 Ti SDK : 5.1.0.v20151028061258, 5.0.3.v20151028061300, 5.2.0.v20151028081229 Ti CLI : 5.0.5 Alloy : 1.7.18 MAC Yosemite : 10.10.5 Appc NPM : 4.2.1-6 Appc CLI : 5.1.0-38 Node: v0.10.37 Nexus 6 : Android 6.0