IOS升级后的imageURI更改应用程序 [英] imageURI changes after IOS upgrade of app

查看:230
本文介绍了IOS升级后的imageURI更改应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jquery移动应用程序(phonegap构建)。我有一个函数,将从设备的照片库中获取图像的uri。我将uri作为字符串存储在本地存储中,以便下次打开页面时,使用uri显示图像。所有这些工作正常(我没有得到的图像的数据-URI,因为我不想使用本地存储,我肯定不想上传的图像到服务器,由于应用程序使用在学校(隐私问题)在设备上是好的,虽然。一切正常,直到我做一个更新的应用程序更新安装后,图像的URI更改如何获取静态URI到所选的图片。这是我用来从图库获取图像的代码。

  // JavaScript文档//获取图片资料
navigator.camera.getPicture(onPhotoURISuccess,onFail,{quality:50,destinationType:
destinationType.FILE_URI,sourceType:Camera.PictureSourceType.SAVEDPHOTOALBUM});

var pictureSource; //图片源
var destinationType; //设置返回值的格式
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;

函数onPhotoURISuccess(imageURI){
//取消注释以查看图像文件URI
console.log(imageURI);
localStorage.setItem(piclink,imageURI)

//获取图像句柄
var largeImage = document.getElementById('largeImage');

//取消隐藏图片元素
largeImage.style.display ='block';

//显示捕获的照片
//内联CSS规则用于调整图像大小
largeImage.src = imageURI;
}
//如果发生错误则调用。
function onFail(message){alert('Failed because:'+ message);
}



我应该提到的是,我应用的更新不会对相机进行任何更改码。所有的数据保持在localstorage罚款,我可以看到,通过控制台它保存和调用URI没有问题,但在URI路径更新后,路径中有一个变化(一个巨大的数字和破折号)。 bTW,Android版本没有问题。任何帮助将非常感谢

解决方案

我的理解是你保存到localStorage的imageURI只是cdv_ *命名的临时文件由CDV Camera插件处理。随着user2603892正确指出,您担心的是应用于更新的新应用程序位置标识符。但是,可能还有几个其他问题要考虑...相机插件顺序命名临时文件作为挑选形式的库,或作为照片。 cdv_photo_001.jpg,cdv_photo_002.jpg等等,直到你做了一个camera.cleanup(),它删除了cdv_ *文件。



插件存储这些文件在/ tmp文件夹中关闭应用程序根目录。显然,iOS不会在更新时复制这些内容。



来自模拟器的示例:imageURI = file:/// Users / xxxxxxx / Library / Application%20Support / iPhone %20Simulator / 7.0.3 /应用程式/ B7B2005C-C116-4BCB-897D-CD46672123C3 / tmp / cdv_photo_001.jpg



建议重新命名并储存档案不是文件的名称)到1)文档文件夹,或2)一个应用程序支持文件夹,然后引用它以备将来使用。



希望这有助于。 / p>

I have a jquery mobile app (phonegap build). I have a function that will get the uri of an image from the device's photo gallery. I store the uri as a string in local storage so the next time the page is opened, the image displays using the uri. All this works fine (I am not getting the Data-UrI of the image because I don't want to use up the local storage, and I certainly do not want to upload the images to a server due to the app being used in a school (privacy issues). on the device is fine, though. Everything works until I do an update to the app. When the update is installed, the URI to the image changes. How can I get a static URI to the selected picture. Here is the code I use to get the image from the gallery.:

  // JavaScript Document  //Get Picture stuff 
  navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType:
  destinationType.FILE_URI, sourceType:Camera.PictureSourceType.SAVEDPHOTOALBUM});

   var pictureSource;   // picture source
   var destinationType; // sets the format of returned value 
   pictureSource=navigator.camera.PictureSourceType;
   destinationType=navigator.camera.DestinationType;

   function onPhotoURISuccess(imageURI) {
   // Uncomment to view the image file URI 
     console.log(imageURI);
     localStorage.setItem("piclink", imageURI)

   // Get image handle
    var largeImage = document.getElementById('largeImage');

    // Unhide image elements
     largeImage.style.display = 'block';

    // Show the captured photo
     // The inline CSS rules are used to resize the image
     largeImage.src = imageURI;
     }
     // Called if something bad happens.
    function onFail(message) {alert('Failed because: ' + message);
     }

I should mention that the update I apply does not make any changes to the camera code. All the data stays in localstorage fine, I can see by the console that it saves and calls the URI with no problem, but in the URI path after update, there is a change in the path (a huge string of numbers and dashes). bTW, there is no problem with the Android version. Any help would be greatly appreciated

解决方案

My understanding is that the imageURI you are saving to localStorage is simply the cdv_* named temporary file as processed by the CDV Camera plugin. As user2603892 correctly pointed out, it appears your concern is the new app location identifier being applied on updates. However, there may be several other issues to consider...the camera plugin sequentially names temp files as picked form the library, or taken as photos. cdv_photo_001.jpg, cdv_photo_002.jpg, etc. This goes on until you do a camera.cleanup(), which removes the cdv_* files.

The plugin stores these files in a /tmp folder off of the application root. Obviously, this would not be copied by iOS on update either.

Sample from Simulator: imageURI = file:///Users/xxxxxxx/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/B7B2005C-C116-4BCB-897D-CD46672123C3/tmp/cdv_photo_001.jpg

A suggestion would be to rename and save your file (not the name of the file) to 1) the Documents folder, or 2) an Application Support folder, and then reference it for future use.

Hope this helps.

这篇关于IOS升级后的imageURI更改应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆