-
Notifications
You must be signed in to change notification settings - Fork 154
Files implementation #110
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
Files implementation #110
Conversation
Concerns:
We could address these in followup work. |
I've added a patch that uses a slightly different approach to the Blob -> File inheritance hierarchy, using the |
2255819
to
36d9c76
Compare
Just to show how ace async fn data_url_future() {
let blob = Blob::new_with_options(PNG_FILE, Some("image/png"));
assert_eq!(
gloo_file::futures::read_as_data_url(&blob).await.unwrap(),
PNG_FILE_DATA
);
}
const PNG_FILE: &'static [u8] = &[
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x25, 0xdb, 0x56,
0xca, 0x00, 0x00, 0x00, 0x03, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x4d, 0x00, 0x5c, 0x35, 0x38, 0x7f,
0x00, 0x00, 0x00, 0x01, 0x74, 0x52, 0x4e, 0x53, 0xcc, 0xd2, 0x34, 0x56, 0xfd, 0x00, 0x00, 0x00,
0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x62, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x36,
0x37, 0x7c, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
];
const PNG_FILE_DATA: &'static str =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAA\
Al21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII="; Now imagine that you got the image from |
bab1765
to
0ac0f79
Compare
ping |
Sorry for the delay on this, I'll get to it soon! |
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.
Sorry for the delay on this, I've been busy with other things.
Overall it looks great, I'm impressed! There's just a bunch of small little nits to fix.
Ok I think I've addressed all the issues from the review, so it should be ready for review again. |
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.
Just a few more small things and this will be ready to land!
Ready for review again. I've experimented with changing the last_modified type to |
@derekdreery I'm torn. On the one hand, it does seem semantically correct. On the other hand, the last modified time must always be after the Unix Epoch, never before. I guess some runtime checking is acceptable. |
Nevermind, I just checked and times before the epoch are valid, so |
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.
Just one more small nit.
Would you like me to squash changes down to a single commit? |
@derekdreery I don't care much either way, so it's up to you. |
Co-authored-by: Ryan Levick <[email protected]> Co-authored-by: Richard Dodd <[email protected]>
1d5f050
to
6cec79e
Compare
I squashed :) |
Thanks a lot! I'm really happy with how this turned out. |
woop woop :) |
I wonder if @alexcrichton would mind commenting on the use of |
I haven't really reviewed this much, but I would agree that using libstd types where possible is the best path to take. |
@alexcrichton really I was just asking if it seems reasonable to use |
This carries on from the work in #83 from @rylev. I've tried to address the issues in that thread.
Closes #47