【问题标题】:How can I create a StorageFile object from URI?如何从 URI 创建 StorageFile 对象?
【发布时间】:2016-12-02 19:01:50
【问题描述】:

我正在开发一个 HTML+JS 应用程序。 我必须在本地照片应用程序中从 Internet 启动图像文件。

要启动的代码:

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
                }
            }
          );
      }
    );

文件有问题,变量应该是StorageFile class。我无法从 URI 创建此类。我应该选择哪种方法(查看链接)?

方法 getFileFromApplicationUriAsync 只从其他应用程序获取文件,而不是从网络获取文件。
createStreamedFileFromUriAsync 方法在 WP 8.1 上不可用。
方法 getFileFromPathAsync 不支持 URI。

【问题讨论】:

    标签: javascript html windows-runtime windows-store-apps winjs


    【解决方案1】:

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

    【讨论】:

    • 您也可以直接启动 HTTP URL,尽管它会在浏览器中打开。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-30
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    • 1970-01-01
    • 2013-04-06
    • 2011-03-02
    相关资源
    最近更新 更多