nhost / hasura-storage

Storage for Hasura built on top of S3
Apache License 2.0
213 stars 42 forks source link

Files Uploading to Default Bucket Despite Specified Bucket-ID #216

Closed SysoevIgor closed 2 months ago

SysoevIgor commented 2 months ago

Hi, I’m using nhost/hasura-storage:0.6.1. I added a new bucket to the buckets table, and when uploading, I specify the new bucket-id. The entries in the files table successfully receive the new value, but all the files I see in MinIO are uploaded to the default bucket. Is this the expected behavior, or did I miss specifying some necessary parameters?

1 2
dbarrosop commented 2 months ago

Hello, thanks for the report. Could you, provide step by step instructions on how to reproduce?

Thanks

SysoevIgor commented 2 months ago

I simply created a bucket called ‘trailers’ in Hasura (the buckets table) and created the same one in MinIO. Then I ran example_curl.sh, where I changed the BUCKET (bucket-id). The files were sent, but only to the default bucket.

dbarrosop commented 2 months ago

Thanks for the explanation. I think this a misunderstanding, hasura-storage's buckets don't map into minio buckets. No matter of which bucket you upload to in the request the file will be uploaded to the bucket you configured on the service when starting it. hasura-storage's buckets are a specific construct of the service to group configuration and permissions so the only thing that setting bucket-id header does is set the appropriate column files.bucket_id, which based on your screenshot works as intended.

Closing as I don't think there is anything to do here but if you have any questions don't hesitate to comment. Thanks again.

SysoevIgor commented 2 months ago

Alright, I understand, thank you. If it’s not possible to change the bucket, is there a way for me to upload a file to a specific folder (which might not yet be created), or will all files be uploaded to the root folder in minio?

dbarrosop commented 2 months ago

That depends on the underlying storage. For instance, s3 doesn't have folders per se but their UI will "pretend" there are folders if you set as filename somefolder/myfile.txt. This is just a UI thing as S3 doesn't really care about files and/or folders (everything is an object). To support that kind of behavior you can do the same with hasura-storage, you can set as filename a full path if needed. My guess is that minio will do the same that s3 does in this regard. So, in summary, just set as filename the full path; /path/to/file.txt.

SysoevIgor commented 2 months ago

Ok, thank you, I’ll give it a try.