# Attachment\_fu and mysql

**URL:** <https://www.ruby-forum.com/t/attachment-fu-and-mysql/108165>\
**Category:** Rails\
**Created:** [June 29, 2007, 3:55pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-mysql/108165 "2007-06-29T15:55:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattclarkson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/958977/32.png) [@mattclarkson](https://www.ruby-forum.com/u/mattclarkson)\
**Post date:** [June 29, 2007, 3:55pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-mysql/108165/1 "2007-06-29T15:55:35Z")

</div>

Hi folks,

I’m using attachment\_fu to upload mp3 files to amazon s3. The files  
are between 1 and 5mb each.

Mostly it works fine, but about 1 in 4 uploads will fail, and once an  
upload fails the app responds erratically, returning proxy errors and  
slowing down overall.

It’s apache/mongrel, with mysql db. I’m watching the log scroll by as  
I upload, and there are no errors thrown.

My only guess so far is that if the upload takes a while between  
laptop to server and then server to amazon, mysql is vulnerable in the  
meantime.

Any ideas on tracking this down, or on how to protect the db during a  
longish update?

controller code follows

thanks much  
@news\_story = NewsStory.find\_by\_id(params[:id])  
@news\_story.update\_attributes(params[:news\_story])  
@news\_story\_soundclip =  
NewsStorySoundclip.new(params[:news\_story\_soundclip])  
if @news\_story.save  
@news\_story\_soundclip.news\_story\_id = @news\_story.id  
@news\_story\_soundclip.save  
flash[:notice] = “Story changes saved.”  
redirect\_to :action =\> ‘list’  
else  
redirect\_to :action =\> ‘edit’, :id =\> params[:id]  
end
