我需要使用带有s3
via的refile
gem将图片上传到Rails-API
。 json
我遵循关于如何使用S3设置refile的refile指南,当我使用curl测试它时,POST请求成功创建但图像没有上传。
请求json数据:
{
"picture": {
"image":"@bin/test.jpg;type=image/jpeg",
"imageable_id":"1",
"imageable_type":"Product"
}
}
卷曲请求:
# curl_post file
create() {
curl -v -X POST \
-H 'Accept: application/json' \
-H "Content-Type: application/json" \
-d @bin/product.json \
http://localhost:3000/api/pictures
}
$1
控制台日志:
Started POST "/api/pictures" for 127.0.0.1 at 2016-02-26 23:04:03 +0200
Processing by Api::PicturesController#create as JSON
Parameters: {"picture"=>{"image"=>"@bin/test.jpg;type=image/jpeg", "imageable_id"=>"1", "imageable_type"=>"Product"}}
(0.2ms) BEGIN
SQL (0.4ms) INSERT INTO "pictures" ("image_id", "imageable_type", "imageable_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["image_id", nil], ["imageable_type", "Product"], ["imageable_id", 1], ["created_at", "2016-02-26 21:04:03.444481"], ["updated_at", "2016-02-26 21:04:03.444481"]]
(33.3ms) COMMIT
Completed 201 Created in 39ms (Views: 0.7ms | ActiveRecord: 34.0ms)