GithubHelp home page GithubHelp logo

Support URLs about fileio.jl HOT 9 CLOSED

juliaio avatar juliaio commented on May 12, 2024 1
Support URLs

from fileio.jl.

Comments (9)

Keno avatar Keno commented on May 12, 2024 3

https://github.com/JuliaWeb/URIParser.jl would be the standard for that.

from fileio.jl.

StefanKarpinski avatar StefanKarpinski commented on May 12, 2024 1

I strongly object to supporting this with plain strings – it's a huge security hole and means that you can't, based on type analysis, know if code is going to try to hit the network or not! I would be in favor of using a URL type for this instead so you would do URL("https://example.com/data.csv"). That's almost as concise and allows us to use dispatch to handle the case of fetching data.

from fileio.jl.

nlw0 avatar nlw0 commented on May 12, 2024 1

Eventually someone pointed me out to the "secret" ImageMagick.load_ function, and I've been a happy user ever since...

from fileio.jl.

timholy avatar timholy commented on May 12, 2024

Thanks, folks---great tips.

from fileio.jl.

nlw0 avatar nlw0 commented on May 12, 2024

I am trying to load an image from the web. Is the recommended way right now to actually save the data to a file and then load from the file? I would like to decode straight from the file contents in memory. Is there any plan to support something like this with ImageMagick, or is it a better idea to just go for a wrapper to the C libraries?

from fileio.jl.

timholy avatar timholy commented on May 12, 2024

Perhaps we should add URIParser as a Requires dependency and have this download the file to a temporary location. Thoughts? Care to tackle it @nlw0?

from fileio.jl.

oxinabox avatar oxinabox commented on May 12, 2024

It is practically really not as simple as it might seem for FileIO.jl to handle this with just the URI.
Because the file-extension often matters for how FileIO works.

And getting the filename (and thus extension) is more complex than one might think.
The first half (about 70lines) of this file is dedicated to using HTTP.jl's systems to work it out.
And it still has edge cases it gets wrong (e.g. you are allowed to use fairly arbitrary character set encodings for some of the fields)
https://github.com/JuliaWeb/HTTP.jl/blob/master/src/download.jl

from fileio.jl.

EricForgy avatar EricForgy commented on May 12, 2024

It is practically really not as simple as it might seem for FileIO.jl to handle this with just the URI.

How about a data URI?

https://en.wikipedia.org/wiki/Data_URI_scheme

I'm currently having some trouble because I receive an image from the browser as a data URI, e.g.

"data:image/jpeg;base64,long-base-64-encoded-string"

and I want to load this into Images.jl preferably without saving it to a file.

The Julia type could be something like:

struct DataURI
    media
    attributes
    binary
    data
end

I'm kind of stuck on this πŸ˜”

from fileio.jl.

timholy avatar timholy commented on May 12, 2024

For common image formats we can use magic bytes. And any format that doesn't have magic bytes is devil-spawn 😈. There are only so many 3-letter combinations out there, I am amazed that people don't always make use of magic bytes.

from fileio.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.