-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[image_picker] Fix path of returned File objects when picking videos #1505
Conversation
Just curious, how did you test camera with simulator? |
I didn't, I just dragged and dropped a MOV file onto the simulator to get it into the videos library. |
@LinusU Thank you for providing this. the .description returns the absolute path to the source. However .path seems to be more relevant to iOS file system and Apple seems suggesting to use .path. Could you provide the use case that the absolute path failed? It seems that dart doesn't care which way the file path was expressed and works for both paths. Also, it is probably a breaking change since the format of the returning value is changed, could you update the minor version? to 0.6.0? |
Since this is an When creating a dart
I'm getting an error that Dart cannot read the file
I don't think it's a breaking change since this works around an error. Even if Hope this clears it up I'll rebase on |
2f36ef8
to
5840688
Compare
I just checked with the the current flutter, it is able to successfully read the file at |
I can confirm this happens for us as well. We have
as a workaround until this gets merged. IIRC, it was as simple as running
|
@LinusU As commented here by @wreppun, people might be doing some surgery on the return value. So it is probably a breaking change for them. I still think we should bump the minor version and make it 0.6.0. |
I agree, let's update the CHANGELOG with a description of new behavior and call it 0.6.0 |
5840688
to
fbc1a91
Compare
Rebased and changed to breaking change 👌 |
fbc1a91
to
6d082d8
Compare
packages/image_picker/CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
## 0.6.0 | |||
|
|||
* Breaking change: Path of returned File objects when picking videos does no longer start with `file:///`, but are instead a normal absolute path. |
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 specify it is on iOS platform. Also the path starts with file:///
is the absolute path, you might want to update the wording a little bit?
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.
Is this better?
Breaking change iOS: Returned
File
objects when picking videos now always holds an absolute path. Before this change, aFile
object with a path beginning with/file:///
could be returned.
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.
Maybe
Breaking change iOS: Returned `File` objects when picking videos now always holds the correct path. Before this change, the absolute path (Begin with file:///) was returned.
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.
(Begin with file:///)
just to clarify, the path returned on the File
object (e.g. print(file.path)
) starts with a single forward slash, and then file:
, followed by three forward slashes. At least on my iPhone 8, iOS 12.2.
This is the code that we are currently using in our app to work around it:
if (file.path.startsWith('/file:///')) {
file = File(file.path.substring(8));
}
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.
Changed to
Breaking change iOS: Returned
File
objects when picking videos now always holds the correct path. Before this change, the path returned could havefile://
prepended to it.
What do you think?
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.
(Begin with file:///)
just to clarify, the path returned on the
File
object (e.g.print(file.path)
) starts with a single forward slash, and thenfile:
, followed by three forward slashes. At least on my iPhone 8, iOS 12.2.This is the code that we are currently using in our app to work around it:
if (file.path.startsWith('/file:///')) { file = File(file.path.substring(8)); }
yeah that was a typo of mine, you can change it to /file:/// in the changelog.
a30d144
to
fb086c1
Compare
fb086c1
to
650d217
Compare
Description
Returning
.description
on aNSURL
gave back an url that starts withfile:///
, when passing this url to theFile
object it constructed a path like/file:///foo/bar/baz.ext
.This fixes this logic to use
.path
instead, which returns the path to the file.Here is some more background to how I found this: https://github.com/firebase/firebase-ios-sdk/pull/2458/files#r276273826
Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
Not sure how to add tests since the tests since to mock out the Objective-C part of the plugins, any help would be appreciated!