简体   繁体   English

如何以编程方式将图像下载到iPad?

[英]How to download image to iPad programmatically?

I have some image files in server. 我的服务器中有一些图像文件。 I need to move or transfer the image files to iPad memory card, so that I can access the image files from the ipad memory card for my iPad application instead of hitting the server to load the image quickly. 我需要将图像文件移动或传输到iPad存储卡,以便可以从iPad应用程序的ipad存储卡访问图像文件,而不必点击服务器即可快速加载图像。

My server side is using java. 我的服务器端正在使用Java。 My client side is using phonegap (javascript, html, css) for iPad. 我的客户端在iPad上使用phonegap(javascript,html,css)。

In server side I am sending the response (response.setContentType("image/gif")) in image format. 在服务器端,我以图像格式发送响应(response.setContentType(“ image / gif”))。 But I am not able to write image file in client side using javascript. 但是我无法使用javascript在客户端写入图像文件。

How to transfer image file to iPad memory storage? 如何将图像文件传输到iPad的存储空间?

Please help me. 请帮我。

You're just trying to download an image using in your Cordova application using Javascript? 您只是想使用Javascript在您的Cordova应用程序中下载图像? I'm downloading PDFs to my app using the following code: 我正在使用以下代码将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)));
            }
        );
    }
}

Perhaps you can use this for your images. 也许您可以将其用于图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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