Heroku file upload problem

前端 未结 5 1723
故里飘歌
故里飘歌 2020-12-15 14:53

I\'ve been having a problem uploading a CSV file to Heroku and processing it. It works fine in my local environment. Just do be clear, I don\'t need to save the file on Hero

5条回答
  •  旧巷少年郎
    2020-12-15 15:11

    Not entirely true, actually. It turns out that if you upload a file to Heroku, you can access it for the duration of the request via the Tempfile class. I was able to read the tempfile into a string and then process it as needed (it's a CSV):

    @file = IO.read(params[:report][:file].path)
    

    Works fine for text/csv files, but I guess if you want to do more than basic text manipulation you have to go with S3 as Joost suggests.

提交回复
热议问题