帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层

[其他] 苹果手机发送icloud图片拉取不成功

[复制链接]
发表于 2021-4-20 10:36:33
苹果手机发送icloud图片拉取不成功
380
帖子
4
勋章
6
Y币
相关代码是什么
(function loopUp(i) {

                if (i === list.length) {
                    api.hideProgress();
                    return;
                }

                var aliyunOSS = api.require('aliyunOSS');

                var path = list[i].path; //文件完整路径  如:A/B/abc.jpg

                aliyunOSS.initOSSClient({
                    endpoint: 'https://oss-accelerate.aliyuncs.com',
                    accessKeyId: '',
                    accessKeySecret: "",
                }, function(ret, err) {
                    if (ret) {
                        aliyunOSS.upload({
                            file: path,
                            bucketName: "im-dj",
                            objectKey: "im" + path,
                            uploadType: 1,
                        }, function(ret, err) {
                            if (ret) {
                                var upLoadUrl = "https://im-dj.oss-accelerate.aliyuncs.com/im" + path;
                                // console.log(upLoadUrl)
                                var progressVal = ret.progress == undefined ? 100 : ret.progress;

                                api.showProgress({
                                    title: '传输中...',
                                    text: '当前进度:' + progressVal + "%"
                                });
                                if (ret.oper === 'complete') { //完成后oper会执行complete

                                    var extStr = extname(path);

                                    if (extStr == 'jpg' || extStr == 'png' || extStr == 'jpeg' || extStr == 'gif' || extStr == 'webp') {
                                        var type = "pic",
                                            msgType = 2;
                                    } else {
                                        type = "video";
                                        msgType = 4;
                                    }

                                    upLoadUrl = msgType == 3 ? upLoadUrl + ',' + type : upLoadUrl;

                                    var obj = {
                                        msgType: msgType,
                                        msgCont: upLoadUrl,
                                        msgTime: type
                                    };

                                    sendMessageFn(obj);

                                    api.hideProgress();

                                    loopUp(++i);

                                }
                            } else {
                                console.log(JSON.stringify(err));
                                api.toast({
                                    msg: '文件上传失败',
                                    duration: 2000,
                                    location: 'middle'
                                });
                            }
                        });
                    }
                });
            }(0))
        }
380
帖子
4
勋章
6
Y币
神州网络技术 发表于 2021-4-21 18:21
(function loopUp(i) {

                if (i === list.length) {

var path = list.path; //文件完整路径  如:A/B/abc.jpg

图片路径怎么来的,哪个模块
技术支持-F 发表于 2021-4-21 22:05
var path = list.path; //文件完整路径  如:A/B/abc.jpg

图片路径怎么来的,哪个模块 ...

    var UIAlbumBrowser = api.require('UIAlbumBrowser');

            UIAlbumBrowser.open({
                max: 6,
                isOpenPreview: false,
                type: 'all',
                styles: {
                    bg: '#fff',
                    mark: {
                        icon: '',
                        position: 'bottom_left',
                        size: 20
                    },
                    nav: {
                        bg: 'rgba(0,0,0,0.6)',
                        titleColor: '#fff',
                        titleSize: 18,
                        cancelColor: '#fff',
                        cancelSize: 16,
                        finishColor: '#fff',
                        finishSize: 16
                    }
                },
                rotation: true,
                selectedAll: false
            }, function (ret) {
                if (ret) {
                    if (ret.list && ret.list.length > 0) {

                        var list = ret.list;

                        api.showProgress({
                            title: '请稍后...',
                            text: ""
                        });

                        if (api.systemType == 'ios') {
                            var aliObjectPath = [];
                            (function loopUp(i) {
                                if (i === list.length) {
                                    uploadAliOss(aliObjectPath);
                                    return;
                                } else if (i < list.length) {
                                    UIAlbumBrowser.transPath({
                                        path: list.path
                                    }, function (ret, err) {
                                        if (ret) {
                                            aliObjectPath.push({
                                                path: ret.path
                                            })
                                            loopUp(++i);
                                        }
                                    });
                                }
                            }(0))
                        } else {
                            uploadAliOss(list);
                        }
                    }
                }

            });
   
技术支持-F 发表于 2021-4-21 22:05
var path = list.path; //文件完整路径  如:A/B/abc.jpg

图片路径怎么来的,哪个模块 ...

    var UIAlbumBrowser = api.require('UIAlbumBrowser');

            UIAlbumBrowser.open({
                max: 6,
                isOpenPreview: false,
                type: 'all',
                styles: {
                    bg: '#fff',
                    mark: {
                        icon: '',
                        position: 'bottom_left',
                        size: 20
                    },
                    nav: {
                        bg: 'rgba(0,0,0,0.6)',
                        titleColor: '#fff',
                        titleSize: 18,
                        cancelColor: '#fff',
                        cancelSize: 16,
                        finishColor: '#fff',
                        finishSize: 16
                    }
                },
                rotation: true,
                selectedAll: false
            }, function (ret) {
                if (ret) {
                    if (ret.list && ret.list.length > 0) {

                        var list = ret.list;

                        api.showProgress({
                            title: '请稍后...',
                            text: ""
                        });

                        if (api.systemType == 'ios') {
                            var aliObjectPath = [];
                            (function loopUp(i) {
                                if (i === list.length) {
                                    uploadAliOss(aliObjectPath);
                 
技术支持-F 发表于 2021-4-21 22:05
var path = list.path; //文件完整路径  如:A/B/abc.jpg

图片路径怎么来的,哪个模块 ...

就是因为我以前的图片在云端。 图片发过去还没有提示
380
帖子
4
勋章
6
Y币
神州网络技术 发表于 2021-4-22 10:43
就是因为我以前的图片在云端。 图片发过去还没有提示

list.path 这是哪来的,哪个接口返回的?
技术支持-F 发表于 2021-4-22 10:50
list.path 这是哪来的,哪个接口返回的?

    var UIAlbumBrowser = api.require('UIAlbumBrowser');

            UIAlbumBrowser.open({
380
帖子
4
勋章
6
Y币
神州网络技术 发表于 2021-4-22 11:05
var UIAlbumBrowser = api.require('UIAlbumBrowser');

            UIAlbumBrowser.open({

https://docs.apicloud.com/Client-API/UI-Layout/WXPhotoPicker
换这个模块看看
12下一页
您需要登录后才可以回帖 登录

本版积分规则