awsm sid
awsm sid

Reputation: 595

How to upload multiple files rails API

Hi am i am working on a RoR project with ruby-2.5.0 and rails 5. I am working on the API i have to write a api to upload multiple images using paperclip. I am using postman i am able to select multiple images from postman but when i send the request i got only one image last image which i selected. How can i upload multiple images?. Please check the screenshot.

enter image description here

Thanks in advance.

Upvotes: 1

Views: 1756

Answers (1)

Anand
Anand

Reputation: 6531

Change field name like pictures[] upload multiple images there.

At controller side

params[:pictures].each do  |picture|
  Model.create(picture: picture)
end

Upvotes: 7

Related Questions