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

Get object #82

Merged
merged 2 commits into from
Jul 4, 2023
Merged

Get object #82

merged 2 commits into from
Jul 4, 2023

Conversation

mmmries
Copy link
Owner

@mmmries mmmries commented Jul 4, 2023

Add support for retrieving a file from the object store. While working on this I came across a few surprising problems (see inline comments for those interested)

@@ -16,9 +16,7 @@ defmodule Jetstream.API.Object do
name: stream_name(bucket_name),
subjects: stream_subjects(bucket_name),
description: Keyword.get(params, :description),
max_msgs_per_subject: Keyword.get(params, :history, 1),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After writing my test for storing and retrieving a large file, I couldn't get the test to pass. I was troubleshooting with the nats CLI tool and realized that when I used the CLI to add a file to my test bucket it also couldn't download the file. Eventually I realized it's because I was creating the bucket with the wrong parameters.

end
end

def info(conn, bucket_name, object_name) do
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change this function in this PR, just moved it up to alphabetize

@@ -90,7 +95,7 @@ defmodule Jetstream.API.Object do
nuid: nuid,
size: size,
chunks: chunks,
digest: "SHA-256=#{Base.encode64(digest)}"
digest: "SHA-256=#{Base.url_encode64(digest)}"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ADR-20 just specific Base64 encoding, but I ran into some cases where the nats CLI was complaining about invalid base64 data. But when I checked in the go client it was actually doing URL-safe base64 encoding https://github.com/nats-io/nats.go/blob/97ccbd884fa75a3a5e86bef0ee4c9374dc0dd2b5/object.go#L317-L319

@mmmries mmmries merged commit 707c87a into object-store Jul 4, 2023
@mmmries mmmries deleted the get_object branch July 4, 2023 14:41
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

Successfully merging this pull request may close these issues.

1 participant