This message was deleted.
# s3gw
a
This message was deleted.
a
What do you see in the s3gw logs when you try to access the REST API? It should show that a request of some kind is being made.
I mean, when you get a 404 accessing the REST API via your application, do you see that same 404 error in the s3gw logs, or do you see something else?
t
Yes, I can also see in the logs that the request resulted in a 404 status:
req 0 0.000000000s s3:put_obj http status=404
====== req done req=0x7f650629e750 op status=0 http_status=404 latency=0.000000000s ======
This are the logs for the entire request. It's 119 log messages. The part where it fails seems to be
s3:put_obj init_permissions on <NULL> failed, ret=-2002
, which sounds to me like the bucket does indeed not exist, but when I log into the UI using the same credentials that I use in my application for my REST requests, the bucket is clearly there.
This is what I see in the UI. When clicking in "Explore", the bucket is empty.
a
I've just noticed, looking at the PUT request, it's
"PUT /3d357e45-30f8-4d4b-b5ec-57f517461666/53a257e6-6fb4-461c-a207-e6cb8d955009 HTTP/1.1"
That looks to me like the client is trying to put to a bucket named "3d357e45-30f8-4d4b-b5ec-57f517461666", not a bucket named "assetbucket".
oh wait, you're trying hostnames for buckets, right? I see
host:assetbucket.localhost:7480
earlier in the log
t
Yes exactly. That entire thing is supposed to be the name of the object I'm trying to create. I'm creating object names by putting together two UUIDs separated by a "/".
Copy code
s3Client.putObject(request -> request.bucket(bucketName).key(assetName)
                .metadata(Map.of(CONTENT_TYPE_ATTRIBUTE, contentType)),
    RequestBody.fromInputStream(data, contentLength));
This is how I'm trying to create the object from my Java application using Amazons S3Client class.
bucketName is "assetbucket" and assetName is the combined UUIDs that you can see in the URL of the PUT request
a
got it. I haven't tried hostname-based buckets myself - I'll try to do some testing tomorrow (apologies, I'm in Australia and it's kinda late here now)
t
Thanks, no problem. I'll look into whether I can configure how the URL is formatted with the S3Client class and if that makes any difference. I did try changing a configuration setting called "forcePathStyle" which didn't seem to have any effect, but I didn't look up what exactly that option means since it didn't work.
👍 1
forcePathStyle does indeed change the way URLs are formatted from hostname-based to path-based. And luckily it does work that way, I'm not getting the 404 status anymore. So now with path-based URLs both those problems have disappeared. I'm getting different errors now in both cases, but they do seem solvable, so I hope it shouldn't be hard to fix them. I'm really not sure why it didn't work when I tried it, but I suspect it was just really bad timing. It might have gone like this: - I configured forcePathStyle = true to try and solve a previous problem (getting a 405 status when trying to create a bucket) - I did not check if it solved that problem - I tried creating the bucket manually from the UI and tried to create an object inside that bucket, which worked - I removed the forcePathStyle configuration since I think it hasn't solved my previous problem - Putting an object inside the bucket stopped working Still, I'm not sure how I could not notice it if it happened that way. Anyway, thanks for helping me find my mistake!
a
Ah, excellent, glad you got it working!
I've also since found out how to make it accept hostname-based buckets. It needs to be run with an extra parameter to tell it the dns name to respond to. You mentioned you're using docker, so I assume you're running something like
docker run -p 7480:7480 <http://quay.io/s3gw/s3gw:latest|quay.io/s3gw/s3gw:latest>
. If you instead use
docker run -p 7480:7480 <http://quay.io/s3gw/s3gw:latest|quay.io/s3gw/s3gw:latest> --rgw-backend-store sfs --debug-rgw 1 --rgw-dns-name localhost
it should let you use hostname based buckets.
(I've got it as
--rgw-dns-name localhost
because you were testing on localhost, but of course if this were a real domain name, you'd use that instead of localhost. The other two parameters
--rgw-backend-store sfs --debug rgw 1
are normally applied automatically, but if you add extra params, everything you add clobbers the defaults, these need to be explicitly specified too)
I've opened a docs issue so we don't lose track of this https://github.com/aquarist-labs/s3gw/issues/754