1

I have jld2 files in an AWS S3 bucket. I managed to set up the connection to the S3 bucket, but how can I load the file?

using AWS
using AWSS3
using JLD2

aws = global_aws_config()
p = S3Path("s3://my/path/to/", config=aws)

pred_columns = JLD2.load(joinpath(p, "file.jld2"), "object_name")

Fatal error:
ERROR: MethodError: no method matching jldopen(::S3Path{AWSConfig}, ::String)

This does not work. What do I need to do here?


Edit: I though it could work as described in this SO post, but it doesn't. It simply tells me that ERROR: ArgumentError: path component is not a string: 0x48, which means, it only accepts a path, but not a byte stream.

Georgery
  • 7,643
  • 1
  • 19
  • 52

1 Answers1

0

OK, so I figured it out and it's probably something that's obvious to real developers. What I needed to do, is actually store the file locally and then load it using the JLD2 package.

using AWS
using AWSS3
using JLD2

aws = global_aws_config()
p = S3Path("s3://my/path/to/", config=aws)

byte_vector = read(joinpath(p, "filename.jld2"))
write(joinpath("to", "my", "file.jld2"), byte_vector)
my_object = JLD2.load(joinpath("to", "my", "file.jld2"), "object_name")
Georgery
  • 7,643
  • 1
  • 19
  • 52