Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@long1eu
Copy link
Contributor

@long1eu long1eu commented Jul 11, 2019

Description

Fix auto-detection of Content-Type for Android.

Related Issues

flutter/flutter#32181

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the [Flutter Style Guide].
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the [CLA].
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@long1eu
Copy link
Contributor Author

long1eu commented Jul 11, 2019

A new issue that I found was related to the leading / on Android.

I/flutter ( 6858): 00:00 +0: FirebaseStorage putFile, getDownloadURL, writeToFile [E]
I/flutter ( 6858):   Expected: 'text/foo44c6da40-8080-11e9-eab5-7d515fb499d2.txt'
I/flutter ( 6858):     Actual: '/text/foo44c6da40-8080-11e9-eab5-7d515fb499d2.txt'
I/flutter ( 6858):      Which: is different.
I/flutter ( 6858):             Expected: text/foo44 ...
I/flutter ( 6858):               Actual: /text/foo4 ...
I/flutter ( 6858):                       ^
I/flutter ( 6858):              Differ at offset 0
I/flutter ( 6858):   
I/flutter ( 6858):   package:test_api/src/frontend/expect.dart 152:30                                                                      fail
I/flutter ( 6858):   package:test_api/src/frontend/expect.dart 146:3                                                                       _expect
I/flutter ( 6858):   package:test_api/src/frontend/expect.dart 59:3                                                                        expect
I/flutter ( 6858):   package:flutter_test/src/widget_tester.dart 212:3                                                                     expect
I/flutter ( 6858):   Users/long1eu/pull_requests/plugins/plugins/packages/firebase_storage/example/test_driver/firebase_storage.dart 31:7  main.<fn>.<fn>
I/flutter ( 6858):   ===== asynchronous gap ===========================
I/flutter ( 6858):   dart:async/future_impl.dart 22:43                                                                                     _Completer.completeError
I/flutter ( 6858):   dart:async-patch/async_patch.dart 40:18                                                                               _AsyncAwaitCompleter.completeError
I/flutter ( 6858):   Users/long1eu/pull_request
I/flutter ( 6858): 00:00 +0 -1: (tearDownAll)
I/flutter ( 6858): 00:00 +1 -1: Some tests failed.

Since documentation for both Android and iOS show images/space.jpg as a result from getPath() I suggest we drop the leading /.

https://firebase.google.com/docs/storage/android/create-reference#reference_properties
https://firebase.google.com/docs/storage/ios/create-reference#reference_properties

@long1eu
Copy link
Contributor Author

long1eu commented Jul 11, 2019

The Android Firebase SDK uses the ContentResolver#getType method to get the MIME type as you can see here.

The issue is that ContentResolver#getType will return null if the scheme is not content://. We could use FileProvider to convert file:/// to content://.

@long1eu
Copy link
Contributor Author

long1eu commented Jul 11, 2019

Another approach, would be to get the Content-Type ourselves and set it on metadata if the user didn't set it already. This approach is also used by the Firebase Storage iOS SDK.

@long1eu long1eu changed the title [firebase_storage][WIP] Fix Content-Type auto-detection for Android [firebase_storage] Fix Content-Type auto-detection for Android Jul 11, 2019
Copy link
Contributor

@collinjackson collinjackson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! You've fixed two inconsistencies between iOS and Android with this PR, and the Android integration test now passes.

@collinjackson collinjackson merged commit c1136f0 into flutter:master Jul 11, 2019
@long1eu long1eu deleted the content_type_autodetection branch July 11, 2019 16:03
mithun-mondal pushed a commit to bKash-developer/archived_plugins that referenced this pull request Aug 6, 2019
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants