Now i having problem about my rails admin dashboard. I have use carrier wave for image uploader on my dashboard. It can be work for image uploader on my dashboard, but in the existing image API has been uploaded, they only show the path of my images not the links for images has been uploaded. If the API accessed by client. it can't be show the image that i have been uploaded, like this:
{
"status": "200",
"message": "OK",
"data": [
{
"id": 5,
"category_name": "Marketplace",
"hex_color": "#f0974a",
"icon": {
"url": "/uploads/category/icon/5/ffffff"
}
},
{
"id": 4,
"category_name": "Finance",
"hex_color": "#28ad60",
"icon": {
"url": "/uploads/category/icon/4/ffffff"
}
So how i can solve the problem of the url that image uploaded can be displayed by API client?
Thanks for your answer
You are looking for the #url
method rather than the #path
method when you construct that json object.
> model.photo_1.path
=> "uploads/photo/1234/original/some_file_name.jpg"
> model.photo_1.url
=> "https://some-bucket.s3.amazonaws.com/uploads/photo/1234/orignal/some_file_name.jpg"