简体   繁体   中英

How can I create a StorageFile object from URI?

I'm working on a HTML+JS app. I have to launch image file from Internet in native photo app.

Code to launch:

var uri = new Windows.Foundation.Uri("http://someuri.com/somefile.JPG");
    Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(
      function (file) {
          // Launch the retrieved file using the default app
          Windows.System.Launcher.launchFileAsync(file).then(
            function (success) {
                if (success) {
                    // File launched
                } else {
                    // File launch failed
                }
            }
          );
      }
    );

There is problem with file variable should be a StorageFile class . I can't create this class from URI. Which method should I choose (look into link)?

Method getFileFromApplicationUriAsync only gets files from other application, not from web.
Method createStreamedFileFromUriAsync isn't available on WP 8.1.
Method getFileFromPathAsync doesn't support URIs.

恐怕您唯一的选择是将文件下载到本地存储,然后从那里下载。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM