Is there a way to get around size limit for “Upload to Photos”

五迷三道 提交于 2019-12-13 08:48:37

问题


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)));

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).

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)?


回答1:


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));

Now I'm back at Can't edit image in Google Photos after "Upload to Photos" activity



来源:https://stackoverflow.com/questions/53990512/is-there-a-way-to-get-around-size-limit-for-upload-to-photos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!