Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Upload photo from Titanium.Filesystem.applicationDataDirectory to Facebook

I know it's possible to upload a photo from Titanium.Media.openPhotoGallery.
But my app relies on saving the photos to the Titanium.Filesystem.applicationDataDirectory.

Is it possible to upload a picture from the filesystem to facebook?

Any suggestions would be appreciated.

— asked November 23rd 2010 by David Aberg
  • facebook
  • iphone
  • mobile
1 Comment
  • can you provide some code for the facebook API? I am assuming it is a simple POST of the image data

    — commented November 23rd 2010 by Aaron Saunders

2 Answers

  • Thanks for the comment.

    Below is the code that uploads a photo from openPhotoGallery. I assume that it might be possible to use Titanium.Facebook.execute('facebook.photos.upload'…) somehow, but don't know how I would implement it.

    function uploadPhoto()
    {
    Titanium.Media.openPhotoGallery({

        success:function(event)
        {
            b1.title = 'Uploading Photo...';
            Titanium.Facebook.execute('facebook.photos.upload',{}, function(r)
            {
                if (r.success)
                {
                    Ti.UI.createAlertDialog({title:'Facebook', message:'Your photo was uploaded'}).show();
                }
                else
                {
                    Ti.UI.createAlertDialog({title:'Facebook', message:'Error ' + r.error}).show();
    
                }
                b1.title = 'Upload Photo';
    
    
            }, event.media);
    
        },
        cancel:function()
        {
    
        },
        error:function(error)
        {
        },
        allowEditing:true
    });
    

    };

    — answered November 24th 2010 by David Aberg
    permalink
    0 Comments
  • I'd like to know this too

    — answered December 7th 2010 by Patrick van Zadel
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.