I'm working on deploying my Rails app to Heroku with Aws S3 to store images, but so far I've failed upload images. My S3 bucket name follows guidelines, and is written like bucket-name. I've checked and my name is the same in heroku config, and in my credential, storage, and production files.
in rails console:
Photo.third.image_file.attach io: File.open("/Users/userName/Downloads/IMG.jpg"),
filename: "image.jpg", content_type: "image/jpg"
returns:
TRANSACTION (2.2ms) COMMIT
S3 Storage (109.0ms) Uploaded file to key: fz63yb7xfj0861sqmdad3x4x2k3z
(checksum: hk9mcGlRlxW7YwkC4uHbEQ==)
Traceback (most recent call last):
1: from (irb):1
Aws::S3::Errors::InvalidBucketName (The specified bucket is not valid.)
and Heroku log shows:
2021-11-28T10:46:57.315492+00:00 heroku[router]: at=info method=GET
path="/api/v1/photos" host=bucket-name-api.herokuapp.com
request_id=36d62d53-4870-40ff-a9bb-1764262d4781
fwd="98.113.64.2" dyno=web.1 connect=0ms service=1288ms status=304 bytes=445
protocol=https
and if I make the request from my React front end Heroku log returns:
2021-11-28T10:56:54.864356+00:00 heroku[router]: at=info method=OPTIONS
path="/api/v1/photos/3/" host=bucket-name-api.herokuapp.com
request_id=2622d278-1b4a-4e77-a6a1-da8a98961fb8 fwd="98.113.64.2" dyno=web.1
connect=0ms service=27ms status=200 bytes=300 protocol=https
2021-11-28T10:56:54.908875+00:00 heroku[router]: at=info method=PUT
path="/api/v1/photos/3/" host=bucket-name-api.herokuapp.com
request_id=d7fe2cb8-8943-4751-b3e3-5779d63f4f83 fwd="98.113.64.2" dyno=web.1
connect=0ms service=17ms status=422 bytes=679 protocol=https