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

AWS S3 put_object results in a "cannot unmarshal string into Go struct" error #266

Open
lmika opened this issue Sep 13, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@lmika
Copy link

lmika commented Sep 13, 2024

Hi,

I'm trying out the AWS S3 client for Risor, and I'm finding that putting an object using put_object would fail with the following error:

json: cannot unmarshal string into Go struct field PutObjectInput.Body of type io.Reader

Here's an sample script of what I'm trying to do:

s3 := aws.client("s3")

func upload_file_to_s3(file, key) {
  bts := os.read_file(file)

  s3.put_object({
    Bucket: "my-bucket",
    Key: key,
    Body: bts,
  })
}

upload_file_to_s3("my-file.txt", "/object/path.txt")

Using os.open() in place of os.read_file would also produce the same error.

I'd imagine it may have something to with how the parameters are converted to the AWS types. These aren't large files so if you know of an alternative field to Body I can use instead, that would work for ne.

@myzie
Copy link
Collaborator

myzie commented Sep 18, 2024

Thanks for reporting this. Haven’t had a chance to diagnose yet but will soon.

@lmika
Copy link
Author

lmika commented Sep 19, 2024

Hi @myzie , thanks for that. I did have a go at hacking a fix for this, which you can find here: lmika@5173609. I've been using it on my fork and it's been working for me (granted, I haven't done a lot of testing of it). I'll be happy to clean it up and raise it as a MR if you're interested.

@myzie myzie added the bug Something isn't working label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants