diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 1694393..f19ea90 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -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 diff --git a/app/models/photo.rb b/app/models/photo.rb index c4ece97..0137d97 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -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