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

Read IOStream for use with S3 #42

Open
rob-luke opened this issue Apr 17, 2015 · 3 comments
Open

Read IOStream for use with S3 #42

rob-luke opened this issue Apr 17, 2015 · 3 comments

Comments

@rob-luke
Copy link

Is it possible to pass an IOBuffer to MAT.jl?

This would be useful when storing data on services such as Amazon S3 with AWS.jl.
I tried the following code, but it did not work.

using AWS
using AWS.S3
env = AWSEnv(); bkt = "???"

file = S3.get_object(env, bkt, "testfile.mat").obj
#IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true, append=false, size=1040, maxsize=Inf, ptr=1041, mark=-1)

vars = matread(file)
# ERROR: `matread` has no method matching matread(::IOBuffer)
@dahong67
Copy link

dahong67 commented Jun 14, 2024

Would be great for this to get a more "proper" fix, but I think a simple (inefficient?) work-around for now could be something along the lines of:

function matread(io::IO)
    # Write to a temporary file
    tempfile = tempname()
    write(tempfile, io)

    # Read data from temporary file
    data = matread(tempfile)

    # Clean up temporary file and return data
    rm(tempfile)
    return data
end

Would need a bit of work to make sure errors, etc. are handled correctly (e.g., what should be done if io is empty?).

@JeffFessler, is this something you're still looking at?

@JeffFessler
Copy link
Member

I found a workaround of the form data = matread(Downloads.download(dataurl)) for my own use, e.g.,
https://juliaimagerecon.github.io/Examples/generated/mri/5-l-plus-s/#Read-data
(You might be amused to see whose work is cited there.)

That does not address the OP question though, and it still (inefficiently?) uses an intermediate file.

@dahong67
Copy link

You might be amused to see whose work is cited there

Fun! Just showed her. :)

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

3 participants