upload testing. ruby 1.9
This commit is contained in:
parent
3f22d112c1
commit
4dafe27067
|
@ -55,11 +55,14 @@ class PhotosController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
RAILS_DEFAULT_LOGGER.info('create method')
|
||||
respond_to do |format|
|
||||
@photo = Photo.new(params[:photo])
|
||||
if params[:Filedata]
|
||||
RAILS_DEFAULT_LOGGER.info('getting file')
|
||||
@photo.swf_uploaded_data = params[:Filedata]
|
||||
if @photo.save
|
||||
RAILS_DEFAULT_LOGGER.info('saved')
|
||||
format.html { render :text => "FILEID:" + @photo.path_modified_public("album") }
|
||||
format.xml { render :nothing => true }
|
||||
else
|
||||
|
|
|
@ -82,7 +82,7 @@ class Photo < ActiveRecord::Base
|
|||
data.content_type = MIME::Types.type_for(data.original_filename)
|
||||
self.title = data.original_filename
|
||||
self.path = self.album.path + "/" + data.original_filename
|
||||
File.open(APP_CONFIG[:photos_path] + self.path, "wb") { |f| f.write(data.read) }
|
||||
File.open(APP_CONFIG[:photos_path] + self.path, :encoding => 'BINARY' ) { |f| f.write(data.read) }
|
||||
RAILS_DEFAULT_LOGGER.info('swf_uploaded_data done')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue