Skip to content
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

Allow reading a TempFile without persisting it #1646

Closed
wants to merge 1 commit into from

Conversation

arnodb
Copy link

@arnodb arnodb commented May 20, 2021

This PR implements an old suggestion to make TempFile implement AsyncRead.

Technically it is an indirect implementation of AyncRead, and it allows conversion to 'static lifetimes via into_owned.

If eventually one calls into_owned in the middle of reading operations (which is strongly discouraged though), then the reading continues where it was left, not at the beginning of the file.

@SergioBenitez
Copy link
Member

I think we should implement anopen() method on TempFile that returns an impl AsyncRead. The concrete type should likely be an Either<File, &'v str> from https://docs.rs/tokio-util/0.6.7/tokio_util/either/enum.Either.html. Then we don't need any manual implementation of AsyncRead nor any intermediary type.

@arnodb
Copy link
Author

arnodb commented May 20, 2021

In the end I don't need it. Two options:

  • I reimplement in the suggested way and we manage to merge this PR if you want it
  • close and forget the PR

This will be your call.

@arnodb arnodb deleted the temp-file-async-read branch May 21, 2021 06:59
@SergioBenitez
Copy link
Member

For posterity: this was closed because we discovered, on Matrix, that the ultimate intent was to store the file upload on Azure. Using TempFile as an intermediary was inefficient and unnecessary, precisely the reason why TempFile does not and likely will not implement AsyncRead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants