# File transfer problem

**URL:** <https://www.ruby-forum.com/t/file-transfer-problem/172699>\
**Category:** Rails\
**Created:** [July 26, 2009, 1:00am UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699 "2009-07-26T01:00:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 26, 2009, 1:00am UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/1 "2009-07-26T01:00:51Z")

</div>

Hello,

my scenario is that i’m using Flex to upload to a remote server. there  
are two servers involved…one that runs the web app and one that only  
stores the file. everytime i do this i get an io error…once, i hit  
the upload button again and it actually did the upload so i decided to  
write the code to do the upload twice (awful hack i know) which works  
only for smaller files. Larger files appear as though the upload is  
happening but still zero length…everything appears to be happening but  
the actual writing of the file…i think this is related to sessions but  
have no way to know for sure what’s happening…is there a way to  
increase the time a session is established?

thanks much

---

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 26, 2009, 11:04am UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/2 "2009-07-26T11:04:20Z")

</div>

I’m not sure if this is what you are looking for, but the session  
cookies don’t get sent by flex/flash when you upload a file. I had to  
make a request before the file upload to get a unique upload id, store  
it the database and return it to flex. Then when I acually send up the  
file I tag it in the params of the upload.

I’m interested to know if anyone came up with a other workarounds for  
the problem?

On Jul 25, 4:00 pm, Percy K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 26, 2009, 1:35pm UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/3 "2009-07-26T13:35:18Z")

</div>

On 26 Jul 2009, at 10:15, Josh wrote:

> I’m not sure if this is what you are looking for, but the session  
> cookies don’t get sent by flex/flash when you upload a file. I had to  
> make a request before the file upload to get a unique upload id, store  
> it the database and return it to flex. Then when I acually send up the  
> file I tag it in the params of the upload.
> 
> I’m interested to know if anyone came up with a other workarounds for  
> the problem?

For more recent versions of Rails (afaik 2.3 or higher):  
[http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue](http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue)

If you’re using an older Rails version, you can check out a post I  
made quite a while ago:  
[http://www.ruby-forum.com/topic/161291](http://www.ruby-forum.com/topic/161291)

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 26, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/4 "2009-07-26T21:30:36Z")

</div>

Hi Peter,

I’ve seen both of these posts, and I’ve implemented the middleware  
solution…ironically…i have no problem uploading to the server  
hosting the web-app…but the problem appears when writing the file to  
the storage server which is auto-linked through nfs…it works fine for  
smaller files, but when i tried to write a 12MB file it fails…is there  
a separate session being established by the storage server or is there a  
session i can get from the server running the web-app in this situation  
(prolonged file transfer).

thanks again

percy

Peter De Berdt wrote:

> On 26 Jul 2009, at 10:15, Josh wrote:
> 
> > I’m not sure if this is what you are looking for, but the session  
> > cookies don’t get sent by flex/flash when you upload a file. I had to  
> > make a request before the file upload to get a unique upload id, store  
> > it the database and return it to flex. Then when I acually send up the  
> > file I tag it in the params of the upload.
> > 
> > I’m interested to know if anyone came up with a other workarounds for  
> > the problem?
> 
> For more recent versions of Rails (afaik 2.3 or higher):  
> [http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue](http://thewebfellas.com/blog/2008/12/22/flash-uploaders-rails-cookie-based-sessions-and-csrf-rack-middleware-to-the-rescue)
> 
> If you’re using an older Rails version, you can check out a post I  
> made quite a while ago:  
> [Need help selecting a good upload plugin - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/161291)
> 
> Best regards
> 
> Peter De Berdt

---

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 26, 2009, 9:37pm UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/5 "2009-07-26T21:37:06Z")

</div>

Hi Josh,  
I’m interested in what you said here:

> to get a unique upload id,

where is this unique upload id and how did you get it? i’m new to ruby  
so although it makes sense i don’t know all the api. are you refering  
to the authenticity token?? i’ve turned mine off so is there another  
unique id i don’t know about?

many thanks

percy

---

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 27, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/6 "2009-07-27T17:20:51Z")

</div>

Hi Zie,  
Excellent suggestions…i’ll give it a shot.

percy

---

<div class="post-metadata">

**Author:** ![rudeluva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rudeluva](https://www.ruby-forum.com/u/rudeluva)\
**Post date:** [July 27, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/file-transfer-problem/172699/7 "2009-07-27T16:41:56Z")

</div>

Hey Percy,

This sounds like a really strange problem. I am thinking a little out  
of the box here, but this sounds like a classic clustering issue. One  
server within the cluster has a different code set or is not working  
correct. Hence you get this case of “it sometimes works and other  
times it doesn’t”. Double check that all your mongrel, or whatever you  
are running, have restarted properly and are running all the same  
code.  
I would highly doubt that this is problem with your flex code if you  
can upload the file properly, even if it is really small. Double check  
that file is not corrupt on the other end though. If you could replace  
your flex code with something else that can handle the same sort file  
transfer, that could isolate the problem.

The only other thing I could think of is a bug within the front end  
server which is handling the file transfer.

Good luck,

Ziemek

On Jul 26, 3:37 pm, Percy K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
