(Rails) Uploading Directories

2019-01-25 21:16发布

问题:

I need to upload multiple files on my website.

But I need not just a form for uploading multiple files, I need to upload whole directories.

How's this possible for the minimalist?

Yours, Joern.

回答1:

According to my somewhat limited knowledge this is not possible, only file transfer is possible, not directories.

Here are some workarounds, based on discussion on Velocity Reviews and another discussion:

  • upload a zip, which you unzip at the server side
  • upload directories over ftp (web page can be a front end to this)
  • upload files one by one

I would go either for zip or ftp. Note: someone might have produced a gem that enables uploading directories (I know nothing of such thing, but I will be happy to find out, if there is).



回答2:

Adding another option to the list provided by Sorrow:

  • upload via REST/JSON

OK, this is a partial solution, but it does give you the opportunity to write a script that reads your directory and POSTS to your website.