Ich habe Schwierigkeiten, heroku mit s3 arbeiten zu lassen. Wenn ich einen Bildbeitrag einreiche, scheint es, dass meine Anwendung ihn einreicht (was ich aus den Heroku-Protokollen ersehen kann). Aber nach der Einreichung wird kein Bild angezeigt, außer für einen leeren Beitrag. Und es gibt kein Bild im s3-Bucket. Ich folgte der Dokumentation von: https://devcenter.heroku.com/articles/paperclip-s3 für s3 und hier: https://github.com/thoughtbot/paperclip für Paperlip.heroku Büroklammer Schienen 4 s3 funktioniert nicht
production.rb
config.paperclip_defaults = {
storage: :s3,
# s3_host_name: 's3.amazonaws.com',
s3_credentials: {
bucket: ENV.fetch('S3_BUCKET_NAME'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
s3_region: ENV.fetch('AWS_REGION'),
}
}
$ heroku config:set S3_BUCKET_NAME=your_bucket_name
$ heroku config:set AWS_ACCESS_KEY_ID=your_access_key_id
$ heroku config:set AWS_SECRET_ACCESS_KEY=your_secret_access_key
$ heroku config:set AWS_REGION=us-east-1
Heroku Logs
2016-12-28T21:57:52.101029+00:00 heroku[web.1]: Unidling
2016-12-28T21:57:52.101275+00:00 heroku[web.1]: State changed from down to starting
2016-12-28T21:57:57.778592+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 30838 -e production`
2016-12-28T21:58:02.108725+00:00 app[web.1]: [2016-12-28 21:58:02] INFO WEBrick 1.3.1
2016-12-28T21:58:02.108742+00:00 app[web.1]: [2016-12-28 21:58:02] INFO ruby 2.2.6 (2016-11-15) [x86_64-linux]
2016-12-28T21:58:02.109000+00:00 app[web.1]: [2016-12-28 21:58:02] INFO WEBrick::HTTPServer#start: pid=4 port=30838
2016-12-28T21:58:02.570577+00:00 heroku[web.1]: State changed from starting to up
2016-12-28T21:58:04.144516+00:00 app[web.1]: => Booting WEBrick
2016-12-28T21:58:04.144539+00:00 app[web.1]: => Rails 4.2.3 application starting in production on http://0.0.0.0:30838
2016-12-28T21:58:04.144541+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-12-28T21:58:04.144541+00:00 app[web.1]: => Ctrl-C to shutdown server
2016-12-28T21:58:04.144542+00:00 app[web.1]: Started POST "/posts" for 162.199.225.97 at 2016-12-28 21:58:04 +0000
2016-12-28T21:58:04.185386+00:00 app[web.1]: Processing by PostsController#create as HTML
2016-12-28T21:58:04.185468+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"L8jVCl6TKg9movpIhk8pt6P9oAv2h7c8sNGHu3n3XhoAke5HgoQuRMncUje71ng/EzSsrBxP5bUBrByTqWALEw==", "post"=>{"content"=>"", "image"=>#<ActionDispatch::Http::UploadedFile:0x007f8aaa6441a0 @tempfile=#<Tempfile:/tmp/RackMultipart20161228-4-mfx8dx.jpg>, @original_filename="best-kitten-names-1.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"best-kitten-names-1.jpg\"\r\nContent-Type: image/jpeg\r\n">}, "commit"=>"Post"}
2016-12-28T21:58:04.205630+00:00 app[web.1]: User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.264197+00:00 app[web.1]: (0.7ms) BEGIN
2016-12-28T21:58:04.268176+00:00 app[web.1]: SQL (1.1ms) INSERT INTO "posts" ("content", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["content", ""], ["user_id", 1], ["created_at", "2016-12-28 21:58:04.264795"], ["updated_at", "2016-12-28 21:58:04.264795"]]
2016-12-28T21:58:04.270377+00:00 app[web.1]: (1.6ms) COMMIT
2016-12-28T21:58:04.271066+00:00 app[web.1]: Redirected to https://immense-gorge-61510.herokuapp.com/users/1
2016-12-28T21:58:04.271231+00:00 app[web.1]: Completed 302 Found in 86ms (ActiveRecord: 12.4ms)
2016-12-28T21:58:04.271721+00:00 heroku[router]: at=info method=POST path="/posts" host=immense-gorge-61510.herokuapp.com request_id=e3e74cff-240a-4041-bc5b-5e4bae727b53 fwd="162.199.225.97" dyno=web.1 connect=0ms service=135ms status=302 bytes=1168
2016-12-28T21:58:04.562237+00:00 heroku[router]: at=info method=GET path="https://stackoverflow.com/users/1" host=immense-gorge-61510.herokuapp.com request_id=b17a22b5-d8f7-4305-860d-7366fbd8e8f1 fwd="162.199.225.97" dyno=web.1 connect=0ms service=143ms status=200 bytes=5100
2016-12-28T21:58:04.425366+00:00 app[web.1]: Started GET "https://stackoverflow.com/users/1" for 162.199.225.97 at 2016-12-28 21:58:04 +0000
2016-12-28T21:58:04.428258+00:00 app[web.1]: Processing by UsersController#show as HTML
2016-12-28T21:58:04.428277+00:00 app[web.1]: Parameters: {"id"=>"1"}
2016-12-28T21:58:04.430570+00:00 app[web.1]: User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.434624+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.438495+00:00 app[web.1]: Post Load (1.0ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = $1 [["user_id", 1]]
2016-12-28T21:58:04.459392+00:00 app[web.1]: (0.9ms) SELECT COUNT(*) FROM "posts" WHERE (user_id = 1)
2016-12-28T21:58:04.470197+00:00 app[web.1]: Post Load (1.1ms) SELECT "posts".* FROM "posts" WHERE (user_id = 1) ORDER BY "posts"."created_at" DESC LIMIT 10 OFFSET 0
2016-12-28T21:58:04.473733+00:00 app[web.1]: User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.489307+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.490576+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.492301+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.493573+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.494749+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.496086+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.497785+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
2016-12-28T21:58:04.498880+00:00 app[web.1]: Rendered shared/_wall.html.slim (34.4ms)
2016-12-28T21:58:04.513974+00:00 app[web.1]: Rendered shared/_error_messages.html.slim (6.4ms)
2016-12-28T21:58:04.515710+00:00 app[web.1]: Rendered shared/_post_form.html.slim (16.2ms)
2016-12-28T21:58:04.515770+00:00 app[web.1]: Rendered users/show.html.slim within layouts/application (73.9ms)
2016-12-28T21:58:04.552423+00:00 app[web.1]: (0.8ms) SELECT COUNT(*) FROM "notifications" WHERE "notifications"."recipient_id" = $1 AND "notifications"."checked" = $2 [["recipient_id", 1], ["checked", "f"]]
2016-12-28T21:58:04.553223+00:00 app[web.1]: Rendered layouts/_header.html.slim (26.5ms)
2016-12-28T21:58:04.560863+00:00 app[web.1]: Rendered shared/_flash_messages.html.slim (6.3ms)
2016-12-28T21:58:04.561408+00:00 app[web.1]: Completed 200 OK in 133ms (Views: 116.4ms | ActiveRecord: 8.2ms)
verwenden Sie den Nebel Edelstein? –
Ich bin nicht. Sollte ich? – user3799793
Ja. Probieren Sie es und auch ImageMagic zum Reduzieren der Dateigröße. Ich sehe nichts in den Holzstämmen, die eine rote Fahne aufwerfen. Nebel ist eine einfache Möglichkeit, Fotos zu S3 zu bringen, und wenn es fehlschlägt, erhalten Sie eine Fehlermeldung. –