1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    12
    Vote Rating
    3
    123e is on a distinguished road

      1  

    Default Unanswered: How I can save image to phone memory?

    Unanswered: How I can save image to phone memory?


    I am trying one code using SA 2.x. I am using Image view in Architect.
    What I am trying is that when I tap on the image that image should get saved to phone memory .
    But no luck. I am getting the image instance but not able to add the download or save functionality

    Pleas help in finding out a solution for this.

    onFullscreenTap: function(img, e, options) {
    Ext.Msg.alert('You clicked the image');
    /* What code should I write here for save or download ? */
    }

    Thanks

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      1  

    Default


    In javascript you don't have access to the filesystem, so this is something you can't do using Sencha Touch only.
    You need to wrap your app into a native environment and use third party frameworks such as PhoneGap to access these functionalities.

    Take a look at this:
    http://docs.phonegap.com/en/2.6.0/co...l#FileTransfer
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  3. #3
    Touch Premium Member hotdp's Avatar
    Join Date
    Nov 2010
    Location
    Denmark
    Posts
    603
    Answers
    8
    Vote Rating
    14
    hotdp will become famous soon enough

      1  

    Default


    Hi,
    You can save the image to LocalStorage as base64 fx.

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Posts
    12
    Vote Rating
    3
    123e is on a distinguished road

      0  

    Default


    @hotdp: I have written a code for LocalStorage but how will I know that the image is saved? I can see some code here Inspect Element -> LocalStorage.
    Can you explain base64 fx.

    Thanks.

  5. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    12
    Vote Rating
    3
    123e is on a distinguished road

      0  

    Default


    @AndreaCammarata : Can you please provide me with some example for this.

  6. #6
    Sencha User
    Join Date
    Feb 2013
    Posts
    12
    Vote Rating
    3
    123e is on a distinguished road

      0  

    Default


    Quote Originally Posted by hotdp View Post
    Hi,
    You can save the image to LocalStorage as base64 fx.
    Please share code . I am stuck here ..
    onTap: function(img, e, options) {
    /* how save image when tap event is fired ? */
    }

    Thanks
    123e

  7. #7
    Sencha Premium Member
    Join Date
    Dec 2012
    Location
    the Netherlands
    Posts
    1
    Vote Rating
    0
    thanhly is on a distinguished road

      0  

    Default


    Hi,

    What you could do is convert the image to Base64 and store the Base64 image in the localstorage.
    However Javascript doesn't allow you to directly retrieve the data inside a <img> element. The solution for that is to use a <canvas> object.

    Check here how to use a canvas object to retrieve a base64 string for the corresponding image:
    http://stackoverflow.com/questions/9...-in-javascript

    Please keep in mind that there is a maximum space for local storage! You can't exceed this space. If I remember correctly, on Safari, once you've hit 5MB it will prompt the user to allow using more memory. However you can't exceed the maximum of 30MB.

  8. #8
    Sencha User
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    89
    Answers
    5
    Vote Rating
    7
    Greg Arnott is on a distinguished road

      0  

    Default


    Sencha have a service for this called Sencha.io.

    Look at the image data conversion description here:
    http://docs.sencha.io/current/index.html#!/guide/src

    The basic use:

    Code:
    http://src.sencha.io/data/http://mysvr.com/images/mypic.jpg
    This will return the image in Base64 format.

    Code:
    imageAsBase64 = "http://src.sencha.io/data/" + imageAbsoluteURL
    Alternatively as a JSONP Callback (to App.myCallBack including the id reference "idRef"):
    Code:
    http://src.sencha.io/data.App.myCallBack-idRef/http://mysvr.com/images/mypic.jpg
    You can also pre-convert your images to Base64 and have them listed in your CSS or code. Now your image is in a data format, it can then be stored with localStorage.
    http://www.sencha.com/learn/taking-s...-apps-offline/ is a guide showing the mechanics of setting that up.
    Last edited by Greg Arnott; 17 Apr 2013 at 8:25 PM. Reason: format

  9. #9
    Sencha User
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    89
    Answers
    5
    Vote Rating
    7
    Greg Arnott is on a distinguished road

      0  

    Default


    If you want to have it just work, the cheesey/simple take I've seen is to launch the image in a new tab/window where the user has the option to tab-hold + save-as.

    A different solution - email them the image. ST can handle the AJAX call to fill in the header, subject, to/from, body and attachment - then have your server email them the image.

    //// a side note:
    Food for thought (download image from an a-tag):

    http://html5-demos.appspot.com/static/a.download.html

    From a phone it just behaves as a target="_blank".

    The major dilema even if this feature was supported either by mobile browsers or Sencha Touch had filesystem support, the overall deal breaker is user permissions. When it comes to phones and photo storage, too many folks shy from allowing a mobile browser/app from accessing.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi