How to save the front page picture, and view the album?

First contact with mixed-use development, then met a lot of H5 + api, call the phone book, scan code, save pictures. Technology destined to make life-long learning, but life-long learning, we can not put all the knowledge and skills have finished school, go to school proficient in the job, we need to work to improve themselves, to sum up the work to grow red.

My project is to develop mui plus H5 +, so the call to wait for the H5 + plusready event occurs when api to normal use.

mui.plusReady ( function () {
      // In it you write api calls 
    plus.downloader.createDownload (url, Options, completedCB);
     // url: Required to download the file url address, only supports network resources address, http or https protocol support 
    // the option: optional 
    // completedCB: optional, triggered when the download is complete, regardless of success or failure will trigger the callback 
    completedCB (download, Status) {}
     // download: Required, download task Object 
    // status: Required to download the results of the status code, the download was successful 200 = status 
    // more successful but did not save the picture is saved to the gallery 
    plus.gallery.save (path, successCB, errorCB) ; this method saves the pictures to the gallery
     // path: Required, saved to a file address album 
    // successCB: Required callback after successfully saved 
    // errorCB: optional, save callback failure 
});
 //The above is a brief document, if you need a detailed understanding of learning, see H5 + api, click to www.html5plus.org/doc/h5p.html 
// The following is the complete code
mui.plusReady ( function () {
    plus.downloader.createDownload(url, {}, function(download,status){
        if(status=200){
            plus.gallery.save( download.filename, function(){
                plus.nativeUI.toast ( "Save Success" );
            }, function(){
                 plus.nativeUI.toast ( "Save failed" );
            });
        }else{
            plus.nativeUI.toast ( "Download failed" );
        }
    });
});

 

These two methods are generally used in combination, my understanding is to create a download task, the pictures downloaded to the local network addresses, and then use plus.gallery.sava () method to save the picture phone system folder inside the copy and paste to your phone gallery for easy viewing.

A summary of the work has just entered from the front end of the white, do not like do not spray, if the wrong places Please indicate!

Guess you like

Origin www.cnblogs.com/xiaoyeya/p/11829133.html