0

我在服务器中有一些图像文件。我需要将图像文件移动或传输到 iPad 存储卡,以便我可以从 ipad 存储卡访问图像文件以用于我的 iPad 应用程序,而不是通过服务器快速加载图像。

我的服务器端正在使用java。我的客户端在 iPad 上使用 phonegap(javascript、html、css)。

在服务器端,我以图像格式发送响应 (response.setContentType("image/gif"))。但我无法使用 javascript 在客户端编写图像文件。

如何将图像文件传输到 iPad 内存存储?

请帮我。

4

2 回答 2

1

你查阅过文档吗?

编辑您可能必须使用插件: http: //blog.clearlyinnovative.com/post/1097750723/phonegap-plugin-for-downloading-url

于 2012-05-21T06:30:54.010 回答
0

您只是想在您的 Cordova 应用程序中使用 Javascript 下载图像?我正在使用以下代码将 PDF 下载到我的应用程序:

function downloadFileToPath(remoteUrl, localPath, successHandler, errorHandler) {
    if (!masseyApp.isInBrowser()) {
        var fileTransfer = new FileTransfer();
        fileTransfer.download(remoteUrl, localPath, 
            function(metadata) {

            console.log("Successfully downloaded " + remoteUrl + " to " + localPath + ".");

            if (successHandler) {
                successHandler(metadata);
            }

            }, 
            function (e) {
                errorHandler(error.createError(ERROR_IO_ERROR, "IO Error", "Failed to download " + e.source + " to " + e.target + " - " + fileErrorToString(e)));
            }
        );
    }
}

也许您可以将它用于您的图像。

于 2012-05-21T13:24:20.693 回答