question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

putFile(Uri) failed : UploadTask: could not retrieve file size for upload android.resource://com.package.name/drawable/ic_drawable

See original GitHub issue

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: _____
  • Firebase Component: 20.0.0 (Database, Firestore, Storage, Functions, etc)
  • Component version: _____

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Relevant Code:

val uploadUri = mProfilePicURI ?: Uri.Builder()
                                .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
                                .authority(resources.getResourcePackageName(R.drawable.ic_user))
                                .appendPath(resources.getResourceTypeName(R.drawable.ic_user))
                                .appendPath(resources.getResourceEntryName(R.drawable.ic_user))
                                .build()
W/UploadTask: could not retrieve file size for upload android.resource://com.myapp.sample/drawable/ic_user
    java.io.FileNotFoundException: Resource does not exist: android.resource://com.myapp.sample/drawable/ic_user

The Uri coming from drawable resource is not working while Uri from file manager, gallery, camera return by ActivityResult works fine such as file:///data/data/com.sample.app/cache/cropped-1168776960.jpg.

What could be the reason behind this? I can use the Uri.Builder value to imagVeiew.setImageUri(uriBuild) so the expectation of it working is reasonable.

Is there a specific format when using Uri? Thanks.

Note: Uploading works successfully despite the issue but the file itself which in this case is an image is not valid file that cannot be viewed or download.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
argzdevcommented, Nov 10, 2021

Yes, I’ve checked correct file and valid image. Perhaps you could provide us an MCVE, so we can investigate this deeper.

0reactions
google-oss-botcommented, Nov 26, 2021

Since there haven’t been any recent updates here, I am going to close this issue.

@ArcherEmiya05 if you’re still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

W/UploadTask: could not retrieve file size for upload ***** java ...
This is the error i get. java.io.FileNotFoundException: Not a whole file at android.content.ContentResolver.openFileDescriptor(ContentResolver.
Read more >
Upload files with Cloud Storage on Flutter - Firebase
Get a download URL; Add File Metadata; Manage Uploads ... You cannot upload data with a reference to the root of your Cloud...
Read more >
Firebase for Android: File Storage
This tutorial will introduce you to the file storage and retrieval functionality available for your Android apps.
Read more >
5 tips for Firebase Storage
Scale: Every file uploaded is backed by Google Cloud Storage, which scales to petabytes. Security: Files can be secured to specific users or ......
Read more >
Uploading Images to Firebase Storage (and retrieving them)
Firebase also contains a Storage feature which allows you to upload files such as images for later retrieval. This is what you're going...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found