上传一个文件与铁路-什么是最好的方法

时间:2022-05-25 04:28:21

I have a requirement of uploading a file to my disk through my webpage. Seems like I have two options

我需要通过我的网页将文件上传到我的磁盘上。看来我有两个选择

My requirement is specific that I will upload ONLY text files.

我的要求是只上传文本文件。

  1. Using default rails methods to upload a file.
    Ex: http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm
  2. 使用默认的rails方法上传文件。例:http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm
  3. Using a plugin like 'PaperClip'
  4. 使用像“PaperClip”这样的插件

Following are my concerns:

以下是我的问题:

  1. I want to keep the file upload as simple as possible
  2. 我想让文件上传尽可能简单。
  3. Keep as away as dependencies like Imagemagic etc
  4. 像Imagemagic等依赖项一样保持距离
  5. I'm using rails 2.8.3
  6. 我使用rails 2.8.3
  7. concurrent file uploads can be happen by multiple users
  8. 并发文件上传可以由多个用户进行。

please can someone tell me what are the pros and cons of having

请告诉我有什么优点和缺点。

  • writing a simple file upload (option 1)
  • 编写一个简单的文件上传(选项1)
  • using a plugin/gem to upload a files
  • 使用插件/gem上传文件

1 个解决方案

#1


4  

Writing your own file uploader is an option, but using a pre-built gem provides you with all of the code you need, straight after install.

编写自己的文件上传程序是一种选择,但是使用预构建的gem就可以在安装之后直接提供所需的所有代码。

Gems will usually have all of the functionality packaged into them that handles all of the cross-platform issues and security headaches your likely to run into by writing something from scratch. A well maintained gem will also have a good community behind it, keeping things up to date.

Gems通常将所有功能打包到其中,用于处理所有跨平台问题和安全性问题,您可能会遇到从头编写代码的麻烦。一个良好维护的gem也将拥有一个良好的社区支持它,使事情保持最新。

The popular Gems out there are really easy to use, and unless you are resizing images etc, you shouldn't need ImageMagick installed. Have a look at these:

市面上流行的Gems非常容易使用,除非你正在调整图像大小等,否则你不需要安装ImageMagick。看看这些:

http://railscasts.com/episodes/134-paperclip

http://railscasts.com/episodes/134-paperclip

https://github.com/technoweenie/attachment_fu/wiki

https://github.com/technoweenie/attachment_fu/wiki

Paperclip is far easier to build a simple upload form with, but I'm not sure if it works on Rails 2. Attachment_fu is an old favorite from the Rails 2 days and will definitely be able to handle your problem, it just requires a little more configuration.

使用Paperclip构建一个简单的上传表单要容易得多,但我不确定它是否适用于Rails 2。Attachment_fu是Rails两天的一个老版本,并且肯定能够处理您的问题,它只需要稍微多一点配置。

#1


4  

Writing your own file uploader is an option, but using a pre-built gem provides you with all of the code you need, straight after install.

编写自己的文件上传程序是一种选择,但是使用预构建的gem就可以在安装之后直接提供所需的所有代码。

Gems will usually have all of the functionality packaged into them that handles all of the cross-platform issues and security headaches your likely to run into by writing something from scratch. A well maintained gem will also have a good community behind it, keeping things up to date.

Gems通常将所有功能打包到其中,用于处理所有跨平台问题和安全性问题,您可能会遇到从头编写代码的麻烦。一个良好维护的gem也将拥有一个良好的社区支持它,使事情保持最新。

The popular Gems out there are really easy to use, and unless you are resizing images etc, you shouldn't need ImageMagick installed. Have a look at these:

市面上流行的Gems非常容易使用,除非你正在调整图像大小等,否则你不需要安装ImageMagick。看看这些:

http://railscasts.com/episodes/134-paperclip

http://railscasts.com/episodes/134-paperclip

https://github.com/technoweenie/attachment_fu/wiki

https://github.com/technoweenie/attachment_fu/wiki

Paperclip is far easier to build a simple upload form with, but I'm not sure if it works on Rails 2. Attachment_fu is an old favorite from the Rails 2 days and will definitely be able to handle your problem, it just requires a little more configuration.

使用Paperclip构建一个简单的上传表单要容易得多,但我不确定它是否适用于Rails 2。Attachment_fu是Rails两天的一个老版本,并且肯定能够处理您的问题,它只需要稍微多一点配置。

相关文章