how to read a User uploaded file, without saving it to the database

后端 未结 2 1135
甜味超标
甜味超标 2020-12-01 02:50

I\'d like to be able to read an XML file uploaded by the user (less than 100kb), but not have to first save that file to the database. I don\'t need that file past the curr

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 03:09

    I need to read yaml files. I use remotipart and here the code:

    in html.slim

     =form_tag('/locations/check_for_import', method: :post, remote: true, multipart: true)
    

    ...

    
    

    in controller

    content = File.read(params[:uploadInput].tempfile)
    doc = YAML.load(content)
    

提交回复
热议问题