2

我需要上传图像以s3使用带有via的refilegem 。我遵循 refile guide 关于如何使用 S3 设置 refile,当我使用 curl 测试它时,POST 请求成功创建,但图像没有上传。Rails-APIjson

请求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)
4

0 回答 0