# Mongrel upload progress: how to validate

**URL:** <https://www.ruby-forum.com/t/mongrel-upload-progress-how-to-validate/77436>\
**Category:** Rails\
**Created:** [November 28, 2006, 12:33am UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-how-to-validate/77436 "2006-11-28T00:33:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mischa78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@mischa78](https://www.ruby-forum.com/u/mischa78)\
**Post date:** [November 28, 2006, 12:33am UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-how-to-validate/77436/1 "2006-11-28T00:33:34Z")

</div>

Hi there,

Another Mongrel upload progress question… I hope you don’t mind.  
(see [http://mongrel.rubyforge.org/docs/upload\_progress.html](http://mongrel.rubyforge.org/docs/upload_progress.html)).

My problem is the following, before uploading the file I want to check  
if it already exists. This is done via a validation in the Myfile model:

validates\_uniqueness\_of :filename, :scope =\> ‘folder\_id’

When I didn’t use upload progress yet this worked fine, but now the  
validation doesn’t get done until after the file is uploaded. Obviously  
this is behaviour I don’t want. It seems the progress starts before  
anything else because of the following in the config file :in\_front =\>  
true. Is there anyway to do this validation before starting the upload  
progress? At the moment I’m clueless…

Thanks!!

Mischa.

---

<div class="post-metadata">

**Author:** ![mischa78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@mischa78](https://www.ruby-forum.com/u/mischa78)\
**Post date:** [November 28, 2006, 2:39am UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-how-to-validate/77436/2 "2006-11-28T02:39:27Z")

</div>

On Nov 27, 2006, at 3:33 PM, Mischa B. wrote:

> validates\_uniqueness\_of :filename, :scope =\> ‘folder\_id’
> 
> Mischa.

Hey Mischa-

```
The mongrel upload progress has to be in_front => true to work. That

```

is the only way for it to know the status of the upload. Mongrel  
keeps an internal progress updater going and tells the upload  
progress handler to increment the progress bar in the browser. But  
control doesn’t come to your rails app until after the entire upload  
is done. AFAIK there is no easy way to do the validation you want to  
do before the prorgess bar is done and the file is already uploaded 😕

Cheers-  
– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![mischa78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@mischa78](https://www.ruby-forum.com/u/mischa78)\
**Post date:** [November 28, 2006, 10:50am UTC](https://www.ruby-forum.com/t/mongrel-upload-progress-how-to-validate/77436/3 "2006-11-28T10:50:17Z")

</div>

Thanks for the feedback.

Now I’m thinking of using Ajax to do the check after the file to upload  
has been selected and before the upload button has been clicked. Does  
anyone have experience with this? Is this possible?

Thanks,

Mischa.

> is done. AFAIK there is no easy way to do the validation you want to  
> do before the prorgess bar is done and the file is already uploaded 😕
