有没有一种方法可以解决“上传到照片"的大小限制, [英] Is there a way to get around size limit for "Upload to Photos"

查看:122
本文介绍了有没有一种方法可以解决“上传到照片"的大小限制,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码共享图像集合:

I'm using this code to share a collection of images:

final ArrayList<Uri> imageUris = new ArrayList<>();
for (final ImageBean selectedImage : ImageBean.getSelectedImageBeans(imagesBeans)) {
    final File imageFile = new File(selectedImage.getPathToImage().getPath());
    final Uri contentProviderUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", imageFile);
    imageUris.add(contentProviderUri);
}
final Intent shareIntent = new Intent();
shareIntent.setType("image/*");
if (imageUris.size() == 1) {
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, imageUris.get(0));
} else {
    shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
    shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
}
context.startActivity(Intent.createChooser(shareIntent, context.getResources().getText(R.string.share_images_intent)));

我主要有兴趣上传到Google相册.这对于600KB的图像非常有用,但是对于5 MB的图像(我的相机为24MP)失败.因此,显然存在大小限制,但是由于Google Photos活动中发生错误,因此我无法对其进行调试(或者我对Android Studio的操作方法不甚了解).

I'm mainly interested in uploading to Google Photos. This works great for an image of 600KB, but fails for a 5 MB image (24MP from my camera). So apparently there's a size limit, but as the error happens in the Google Photos activity, I'm unable to debug it (or I don't know Android Studio well enough on how to do that).

有没有一种方法可以更改我的Intent,以便我可以上传多个24MP图像,或者是否指定了大小限制,并且需要解决(例如,通过实现Google Photos API)?

Is there a way I can change my Intent so I can upload multiple 24MP images, or is the size limit a given and I need to work around it (eg. by implementing the Google Photos API)?

推荐答案

事实证明,Google Photos在FileProvider中不能很好地发挥作用.使用公共内容URI 进行上传时,可以使用类似的

It turns out that Google Photos doesn't play well with the FileProvider. The upload works when using the public content URI, to be found using something like

int mediaId = cursor.getInt(getColumnIndexForMediaID());
Uri publicUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(mediaId));

现在,我回到了可以在上传到照片"之后,不要在Google相册中编辑图像;活动

这篇关于有没有一种方法可以解决“上传到照片"的大小限制,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆