Skip to content

Commit

Permalink
Removed the thumbnail choice on upload and move processing into a ren…
Browse files Browse the repository at this point in the history
…der_then_call block. Necessary because generate_thumbnail_selection can take a very long time for large videos.
  • Loading branch information
Martyn Loughran committed Oct 7, 2008
1 parent 5f6341e commit fb302f9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions app/controllers/videos.rb
Expand Up @@ -85,18 +85,8 @@ def upload
# @video.process
@video.valid?
@video.read_metadata
@video.upload_to_s3

# Generate thumbnails before we save so the encoder doesn't get there first and delete our file!
if Panda::Config[:choose_thumbnail]
@video.generate_thumbnail_selection
else
@video.add_to_queue
end

@video.status = "original"
@video.save
FileUtils.rm @video.tmp_filepath
rescue Amazon::SDB::RecordNotFoundError # No empty video object exists
self.status = 404
render_error($!.to_s.gsub(/Amazon::SDB::/,""))
Expand All @@ -112,12 +102,20 @@ def upload
else
case content_type
when :html
url = Panda::Config[:choose_thumbnail] ? "/videos/#{@video.key}/thumbnail/new?iframe=true" : @video.upload_redirect_url
url = @video.upload_redirect_url

# Special internal Panda case: textarea hack to get around the fact that the form is submitted with a hidden iframe and thus the response is rendered in the iframe
if params[:iframe] == "true"
"<textarea>" + {:location => url}.to_json + "</textarea>"
html = "<textarea>" + {:location => url}.to_json + "</textarea>"

render_then_call html do
@video.upload_to_s3
@video.generate_thumbnail_selection
@video.add_to_queue
FileUtils.rm @video.tmp_filepath
end
else
# Need redirect then call
redirect url
end
end
Expand Down

0 comments on commit fb302f9

Please sign in to comment.