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

Feature request urls #7

Closed
Firtzberg opened this issue Oct 19, 2019 · 4 comments
Closed

Feature request urls #7

Firtzberg opened this issue Oct 19, 2019 · 4 comments

Comments

@Firtzberg
Copy link
Contributor

Thank you for the package.
I am trying to include a file from s3 in my zip. I noticed the link gets included as text. The thing is I only have access to a temporary url, which starts with http://, rather than s3://.
Would it be possible that File::make() autodetects URLs and streams them, rather than including them as textual content?
Since fopen() can be used for files and URLs I assume the UrlFile would look similar to LocalFile.

@Firtzberg
Copy link
Contributor Author

Firtzberg commented Oct 19, 2019

Maybe in File::make() when providing a local file you can change the if statement to
if (file_exists($source) || filter_var($source, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED|FILTER_FLAG_HOST_REQUIRED|FILTER_FLAG_PATH_REQUIRED))

@Firtzberg
Copy link
Contributor Author

The more I think about this it appears that you had support for this before creating TempFile and lost it then.

@jszobody
Copy link
Member

Supporting URLs is tricky.

We need to know the size of the source up front, to calculate the total zip filesize. This is done before any file contents are retrieved. While some URLs would provide a content-length header, many do not. The only way to reliably support URL sources would be to download the entire source contents first, which would block the zip. Large sources would possibly block for some time, which really goes against the entire goal of this package (provide instant-start zip streaming to the end user, with size calculated up front).

That's why so far I've only added support for s:// paths, since we can use the AWS API to lookup the size for those.

@Firtzberg
Copy link
Contributor Author

Thank you for the explanation. That makes sense.
It might be possible to do this using the LocalFile with size estimation disabled.

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

No branches or pull requests

2 participants