-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Bugfix/upload via share #1920
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
Bugfix/upload via share #1920
Conversation
* Added a java library to fetch the MIME type from input stream * Fetch MIME type using this and use the contribution tag only when this fails:
Thanks for the quick PR! A couple of things:
|
@misaochan Tests-> I have manually tested by uploading both png and jpeg images (via Share as well) confirming the extensions from the file info, both of them went to success (on Google Pixel where I could produce the issue easily as mentioned in the issue thread) |
File file1 = new File(contribution.getLocalUri().getPath()); | ||
fileInputStream = new FileInputStream(file1); | ||
tempFileInputStream = new FileInputStream(file1); | ||
if(contentInfoUtil==null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use consistent formatting. :) E.g. see the catch block below for our usual bracket formatting
@@ -222,9 +240,17 @@ private void uploadContribution(Contribution contribution) { | |||
|
|||
String filename = null; | |||
try { | |||
//try to fetch the MIME type from contentInfo first and then use the tag to do it | |||
//Note : the tag has not proven trustworthy in the past |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good documentation! 👍
String mimeType; | ||
if(contentInfo==null || contentInfo.getMimeType()==null){ | ||
mimeType=(String)contribution.getTag("mimeType"); | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting please
@ashishkumar468 Thanks for the explanation, in that case I agree that the new library is needed as more than just a convenience. :) I tested this on a Nexus S emulator on API 27, and indeed .png uploads via Share and the app work for me, and no issues with other filetypes either. Great job! 👍 We just need you to make a few formatting changes, and we also need 1 more person (@neslihanturan , @maskaravivek ?) to approve the new library. Then I'll merge and release the hotfix with this. |
Codecov Report
@@ Coverage Diff @@
## 2.8-release #1920 +/- ##
==============================================
- Coverage 3.73% 3.72% -0.01%
==============================================
Files 190 190
Lines 9537 9555 +18
Branches 849 852 +3
==============================================
Hits 356 356
- Misses 9156 9174 +18
Partials 25 25
Continue to review full report at Codecov.
|
@ashishkumar468 The build is failing for me. I was basically trying to check the method count for this build. Without this build, master has |
@maskaravivek Not sure about the build failure, please try cleaning the project. And yeah regarding the method count, I have checked in both the apk's one without this library and one with the library, total method counts in both is ~17 k self and 25 k referenced hardly differing in 20-30 methods. Also, there is negligible change in apk size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. The library isn't adding a lot of extra methods to the application and looks to be useful.
Thanks Ashish! |
* Bug Fix commons-app#1878 * Added a java library to fetch the MIME type from input stream * Fetch MIME type using this and use the contribution tag only when this fails: * formatting changes, removed unused commented out line
* Bugfix/upload via share (#1920) * Bug Fix #1878 * Added a java library to fetch the MIME type from input stream * Fetch MIME type using this and use the contribution tag only when this fails: * formatting changes, removed unused commented out line * Versioning and changelog for v2.8.5 (#1923) * Versioning for v2.8.5 * Update changelog.md
I know that this PR is closed, but why was a jar file used instead of a gradle reference? |
Sometimes uploads fails or queued, then don't upload. #1878
Fixes #1878 Sometimes uploads fails or queued, then don't upload.
Description (required)
As the app was unable to validate the MIME type of the image shared via intent or from any source, the api to upload image used to fail because the backend was smart enough to validate the same
Fixes #{GitHub issue number and title}
{Describe the changes made and why they were made.}
Added a java library to validate the image MIME type and accordingly append the image extension.
Tests performed (required)
Tested on {27 & Google Pixel}, with {build variant, ProdDebug}.
Screenshots showing what changed (optional)
NA