Skip to content
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

如何将图片在加载之前上传至服务器? #72

Open
weishubaoforwork opened this issue May 29, 2019 · 10 comments
Open

如何将图片在加载之前上传至服务器? #72

weishubaoforwork opened this issue May 29, 2019 · 10 comments

Comments

@weishubaoforwork
Copy link

我看到ARE_Toolbar.class中的OnActivityResult中存在:
if (REQ_IMAGE == requestCode) {
Uri uri = data.getData();
this.mImageStyle.insertImage(uri, AreImageSpan.ImageType.URI);
}
此时在调用了AREditer的Actvity中的OnActivityResult仅仅是实现了
this.arEditor.onActivityResult(requestCode, resultCode, data);

我希望在图片加载AREditer之前,将图片的uri在调用了AREditer的Activity中得到,并且完成上传后,再加载图片进入AREditer。

@weishubaoforwork
Copy link
Author

weishubaoforwork commented May 29, 2019

在主Activity中的result写成如此,不知道能否有效?
if (requestCode==1){
Uri uri=data.getData();
File file=uriToFile(uri,AcDetailEditActivity.this);
GreenDaoManager greenDaoManager=GreenDaoManager.getInstance(AcDetailEditActivity.this);
Map<String ,String> datas=new HashMap<>();
datas.put("token",greenDaoManager.getUser().getSignature());
datas.put("activityId",uuidString);
datas.put("filePath",uri.toString());
HttpUtil.getInstance().httpUpLoadImage(INTERAPI + "/activityImgUpload", file, datas, new HttpUtil.ResultCallback() {
@OverRide
public void onError(String msg) {

            }

          @Override
            public void onSuccess(String result) {
                arEditor.onActivityResult(requestCode, resultCode, data);
            }
        });

@chinalwb
Copy link
Owner

@chinalwb
Copy link
Owner

#56 这个是同样的问题.

@weishubaoforwork
Copy link
Author

你好,集成了这个,但是我没有在doInBackgourd中无法得到Context,没有办法做上传,这个该怎么解决呢?

@chinalwb
Copy link
Owner

你好. 但是我没有在doInBackgourd中, 没在doInBackground做上传吗? 是不是没有用 AsyncTask?

void uploadAndInsertImage(Uri uri, ARE_Style_Image areStyleImage);

这个回调方法当中有一个 ARE_Style_Image. 你可以通过这个的 getEditText 方法得到 EditText 然后就可以得到 context 了.

@weishubaoforwork
Copy link
Author

对的。我现在使用了你推荐的方法,因为有doInBackGround,参数中的uris我不能理解
File file = new File(new URI(uris[0].toString()));无法得到File,

我现在是使用文件上传的,还希望能给个帮助。

我现在的参数是File,user的某个值,但是我却不知道怎么得到File

@chinalwb
Copy link
Owner

Here you go:

Convert file: Uri to File in Android
https://stackoverflow.com/a/8370299/853191

@weishubaoforwork
Copy link
Author

我尝试了很多次,发现AREditor没有走ImageStrategy,使用AREditext并重写了Selecttor后得以解决。辛苦大神

@chinalwb
Copy link
Owner

厉害!

@weishubaoforwork
Copy link
Author

通过网络加载,这似乎也解决了之前加载图片时android8的bug,大神你有空可以看看这个问题。貌似网络加载没有android8的那个闪退bug

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

2 participants