aliyun / aliyun-oss-react-native

MIT License
148 stars 101 forks source link

上传图像在Android emulator运行通畅但在安桌手机上stuck #90

Open emclab opened 2 years ago

emclab commented 2 years ago

应用是RN 0.66。 以下是code。保存image在安卓手机上总是在进行中,也不出错。怀疑是Init有network错误。App已经允许http

android:usesCleartextTraffic="true"

如何fix这个问题?

import AliyunOSS from 'aliyun-oss-react-native';
AliyunOSS.initWithSecurityToken(STSConfig.SecurityToken,STSConfig.AccessKeyId,STSConfig.SecretKeyId,endPoint,configuration);  //《〈==network Error?
    const saveOSS = async (bucket_name, objkey, filePath) => {
        return (new Promise((resolve) => {
            AliyunOSS.asyncUpload(bucket_name, objkey, filePath).then( (res) => {
                //console.log("Success : ", res);
                resolve(true);
            }).catch((error)=>{
                setTimeout(()=> {
                    AliyunOSS.asyncUpload(bucket_name, objkey, filePath).then((res) => {
                        //console.log("Success : ", res);
                        resolve(true);
                    }).catch((error)=>{
                        resolve(false);
                    })
                }, 20);
            })
        }));
    };
emclab commented 2 years ago

Screenshot_20220126_103702_com xyz_app5

Screenshot_20220126_103705_com xyz_app5