Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-19784](5_0_X) Android: Cloud Files Create Error #7352

Merged
merged 2 commits into from Oct 27, 2015

Conversation

ashcoding
Copy link
Contributor

Jira: https://jira.appcelerator.org/browse/TIMOB-19784

Testing Steps

  1. Create a new project with cloud services enabled.
  2. Place a text file with some content mytestfile.txt in resources. Eg resources/mytestfile.txt
  3. Run the code below:
Titanium.UI.setBackgroundColor('#000');

var win = Titanium.UI.createWindow({  
    title:'TIMOB-19784',
    backgroundColor:'#fff'
});


var button = Titanium.UI.createButton({
    title:'Press to Upload',
    top: 100
});

win.add(button);

var ACS = require('ti.cloud');

button.addEventListener('click', function(e) {

    ACS.Files.create({
                    name: 'thisUniqueName',
                    file:  Ti.Filesystem.getFile("mytestfile.txt")
                }, function (e) {
                    if (e.success) {
                         Ti.API.info(JSON.stringify(e));
                         alert("Success: " + JSON.stringify(e));
                    } 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){
        alert("login success!");
        Ti.App.fireEvent('login.success',result.users[0],env);
    } else {
        alert("login failed!");
        Ti.App.fireEvent('login.failed',result,env);
    }
});

})();

@hansemannn hansemannn changed the title [TIMOB-19784] Android: Cloud Files Create Error [TIMOB-19784](5_0_X) Android: Cloud Files Create Error Oct 27, 2015
@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted

hieupham007 added a commit that referenced this pull request Oct 27, 2015
[TIMOB-19784](5_0_X) Android: Cloud Files Create Error
@hieupham007 hieupham007 merged commit bff8252 into tidev:5_0_X Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants