RoR: check the downloaded file

I need to check the bit of the downloaded file before saving it to the file system. The PHP documentation has a nice page that tells me which properties are available to me ( http://us3.php.net/manual/en/features.file-upload.post-method.php ), but I can not find something similar to Ruby and / or Rails.

I also tried registering a JSON string as loadable, but that just gives me a redundant UTF-8 error. I can't think of anything else to try.

Can someone suggest any kind of understanding or point me to the right place?

Thank.

UPDATE: I am running Apache 2.2.11 on OS X (Leopard) if Peter is right (see below).

UPDATE: In case this helps, my input parameter is logged as "upload"=>#<File:/tmp/RackMultipart.64239.1>. I'm just not sure how to access it in order to get to its “parts”.

0
source share
4 answers

As far as I can tell or not, there is no physical file until the download is read. This is built in with a confirmation response. Only metadata is available:

uploaded_file.content_type  # the uploaded file MIME type
uploaded_file.original_path # which is really just the name of the file

In addition, there is a readmethod uploaded_filethat allows access to the contents of a file and is supposedly written to a permanent file system.

- , , , Ruby MIME content_type . , MIME.

+4

, -. , mongrel, apache nginx.

0

File, , :

File.open("some_file")

/tmp/RackMultipart.64239.1 - .

/ :

 puts params[:upload].read
0

Source: https://habr.com/ru/post/1773746/


All Articles