简体   繁体   English

如何上传多个文件Rails API

[英]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. 嗨,我正在开发一个使用ruby-2.5.0和rails 5的RoR项目。我正在开发API,我必须编写一个api以使用回形针上传多个图像。 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. 请检查屏幕截图。

在此处输入图片说明

Thanks in advance. 提前致谢。

Change field name like pictures[] upload multiple images there. 更改字段名称,例如pictures[]在那里上传多个图像。

At controller side 在控制器端

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM