- 发布:2015-06-05 23:59
- 更新:2018-06-11 13:51
- 阅读:12537
最佳回复
var NSData = plus.ios.importClass('NSData');
var nsData = new NSData();
var path = plus.io.convertLocalFileSystemURL('_doc/test.jpg');
//此处传入image的base64数据
nsData = nsData.initWithBase64EncodedStringoptions("iVBORw0KGgoAAAANSUhEUgAAABgAAAAsCAYAAAB/nHhDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNC8yOC8xMqLz6JEAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAABJ0lEQVRYhe3Wv6rCMBQG8C/VN1AEd3HSzuYO3jr4knkY0UE62xTBcp9A8A0uHhc72CZp/lQQyZmT7xfSJKeMiPDOSt6aHoEIRKAbkLKioqiCrroWkLKi+51ARAhBlEAdXlcI0gLK8u8lPBRpAYvFjCUJUw72QZRbtFzOe0O0H7kvxHhM83yfhiJdF+2c5/utCTmdLnS93rQQs2mZQogN59lOdbrqmk7HmExGrZVYAU9kzXl2cEWsgSfys1r9Hk1TmogTAABFcTFOaQJOr6mUlVO4E9B8n2zCrQHfcAAYmoKFEAPOs39dOGMMaTpXX5J6jGlTTSu3CQcsGk5IuBboK1wJ6BqOT7gS0DUcn3AlALR7gW84YHGKiOAd3gn0UV/+6xiBCHwG8AByzMrOPKV7sAAAAABJRU5ErkJggg==",0);
if (nsData) {
nsData.plusCallMethod({writeToFile:path,atomically:true});
plus.ios.deleteObject(nsData);
}
安卓已经搞定 使用BITMAP 安卓和IOS都可以使用
-
/将BASE 64保存为文件/
function saveHeadImgFile(uid,base64,quality,cback){
var bitmap = new plus.nativeObj.Bitmap("test");
// 从本地加载Bitmap图片
bitmap.loadBase64Data(base64,function(){
// console.log('加载图片成功');
bitmap.save( "_doc/"+uid+".jpg",{overwrite:true,quality:quality},function(i){
cback();
// console.log('保存图片成功:'+JSON.stringify(i));
},function(e){
console.log('保存图片失败:'+JSON.stringify(e));
});
},function(e){
console.log('加载图片失败:'+JSON.stringify(e));
});
}2016-04-13 15:14
马克_SHI (作者)
var NSData = plus.ios.importClass('NSData');
var nsData = new NSData();
var path = plus.io.convertLocalFileSystemURL('_www/test.jpg');
nsData.initWithBase64EncodedStringoptions(base64,0);
nsData.writeToFileatomically(path,true);
我这样操作的,但是写入的文件是空的,求救!!
马克_SHI (作者)
可以了,感谢大神的支持!!!
2015-06-29 17:19
简小单
回复 马克_SHI:请问安卓怎么弄?
2016-03-11 14:11
Johnson
[ERROR] : TypeError: undefined is not an object (evaluating 'nsData.plusCallMethod')
nadata是 undefined 是什么情况
var NSData = plus.ios.importClass('NSData');
var nsData = new NSData();
var path = plus.io.convertLocalFileSystemURL('_doc/'+photo.fileName);
nsData = nsData.initWithBase64EncodedStringoptions(photo.base64,0);
nsData.plusCallMethod({writeToFile:path,atomically:true});
plus.ios.deleteObject(nsData);
delete photo.id;
photo.path = path;
photo.ownerid = task.workorderid;
2016-07-22 16:08
1***@qq.com
支持png图片吗
2017-04-05 12:01
安小白
保存是保存成功了,但是为甚么ios上传一直失败?
2018-06-12 15:39