Skip to content

公告:这个SDK后面有时间准备重新搞起来了,大家有issue,有PR的欢迎可以提交 #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
luozhang002 opened this issue May 26, 2021 · 17 comments

Comments

@luozhang002
Copy link
Collaborator

No description provided.

@Joyor
Copy link

Joyor commented Jun 9, 2021

希望更新一下这个

@Shik1997
Copy link

非常需要!

@kala888
Copy link

kala888 commented Sep 7, 2021

然后呢?没有然后了?

@lh9403
Copy link

lh9403 commented Sep 14, 2021

没下文了,怕是作者一直没有时间

@suwu150
Copy link

suwu150 commented Sep 28, 2021

?

@emclab
Copy link

emclab commented Dec 1, 2021

RN 0.66.3版本Xcode build出很多错误。

@emclab
Copy link

emclab commented Dec 1, 2021

如果是个人维护,时间有限,或许可以考虑募捐资助作者进行module维护和更新。

@alantoa
Copy link

alantoa commented Jan 20, 2022

https://github.com/hufans/react-native-alioss
可以关注下这个库,支持ts

@emclab
Copy link

emclab commented Jan 24, 2022

alantoa, 有使用经验可以分享吗?react-native-aliosssize小很多。我的使用环境是RN 0.66, both android/ios。主要是上传图像到OSS。Many thanks.

@alantoa
Copy link

alantoa commented Jan 24, 2022

@emclab 简单测试了一下,两个库 Api 都是一样的,这里有问题的,react-native-alioss 也会又问题,但是react-native-alioss sdk 会新一点,然后增加了 ts 的类型,作者也在维护。
然后说一下这个库是在 aliyun 组织下的,阿里云咱们用都也是付费服务,相应的阿里云也应该提供维护,但是这个库已经三年多不维护了,我提的 PR 也无人问津,九成是弃坑了,建议换掉吧,react-native-alioss 后面遇到问题的话我也会提PR。

@emclab
Copy link

emclab commented Jan 28, 2022

alantoa, 谢谢input。会考虑测试一下。我现在碰到一个棘手的问题,就是在安卓手机上传图像到OSS会出找不到文件的错误。但在安卓emulator上却没有同样的问题。不知道这个问题是否跟OSS模块有关系。

@emclab
Copy link

emclab commented Jan 28, 2022

alantoa, 但是react-native-alioss sdk 会新一点, 你是指·react-native-alioss call 的OSS sdk 比这个模块call的版本更新?如果sdk更新,是不是模块会运行得更好?

@alantoa
Copy link

alantoa commented Jan 30, 2022

这个是oss库,不会出现文件找不到的情况,你排除下是否是因为读写权限的问题或者是图片选择器的问题

@emclab
Copy link

emclab commented Jan 31, 2022

问题确实很奇怪。已经试了另外一个popular的image picker,错误是一样的,这样基本可以排除image picker。我也怀疑是权限问题。在Android Manifest目前已经给了5个权限:

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" /> 
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

不知道还缺什么权限。会需要给OSS模块单独授权吗?

@emclab
Copy link

emclab commented Feb 3, 2022

alantoa, 问题应该是android10用的是scoped storage,每个应用存储在自己的子目录下。而Android9以前,应用是共享一个存储子目录。本OSS库不知道scoped storage,而是仍然用共享存储,因此在Android10上出错。以下是关于EXTERNAL_STORAGE的文章

if (android.os.Build.VERSION.SDK_INT < 29) {

     // ==>  /storage/emulated/0    (Emulator)
     File dir = Environment.getExternalStorageDirectory();
} else if (android.os.Build.VERSION.SDK_INT >= 29) {
     // ==> /storage/emulated/0/Android/data/org.o7planning.externalstoragedemo/files
     File dir = this.getExternalFilesDir(null);
}

本库对全部Android版本都仅仅使用了Environment.getExternalStorageDirectory();。这也就是为何在错误信息中显示的是共享路径(Android9以前)的原因。本库的AliOssUploadManager.javaFileUtils.java需要update。或许还有其他的也需要update。

@emclab
Copy link

emclab commented Feb 3, 2022

the following code change in FileUtils.java works in Android 10 emulator:

import android.os.Build;
public static String getFilePathFromURI(Context context, Uri contentUri) {
        //copy file and send new file path
        String fileName = getFileName(contentUri);
        if (!TextUtils.isEmpty(fileName)) {
            File copyFile;
            if (Build.VERSION.SDK_INT >= 29) {
            // ==> /storage/emulated/0/Android/data/org.o7planning.externalstoragedemo/files
                copyFile = new File( context.getExternalFilesDir(null).getAbsolutePath() + File.separator + fileName);
            } else {
                copyFile = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + fileName);
            }
            
            FileUtils.copy(context, contentUri, copyFile);
            return copyFile.getAbsolutePath();
        }
        return null;
    }

@newyoung21
Copy link

the following code change in FileUtils.java works in Android 10 emulator:

import android.os.Build;
public static String getFilePathFromURI(Context context, Uri contentUri) {
        //copy file and send new file path
        String fileName = getFileName(contentUri);
        if (!TextUtils.isEmpty(fileName)) {
            File copyFile;
            if (Build.VERSION.SDK_INT >= 29) {
            // ==> /storage/emulated/0/Android/data/org.o7planning.externalstoragedemo/files
                copyFile = new File( context.getExternalFilesDir(null).getAbsolutePath() + File.separator + fileName);
            } else {
                copyFile = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + fileName);
            }
            
            FileUtils.copy(context, contentUri, copyFile);
            return copyFile.getAbsolutePath();
        }
        return null;
    }

@emclab 什么时候发包更新呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants