Module: Hydra::Controller::UploadBehavior
- Defined in:
- lib/hydra/controller/upload_behavior.rb
Instance Method Summary collapse
-
#add_posted_blob_to_asset(asset, file, file_name) ⇒ FileAsset
Puts the contents of params (posted blob) into a datastream within the given @asset Sets asset label and title to filename if they’re empty.
-
#create_and_save_file_assets_from_params ⇒ FileAsset
Creates a File Asset, adding the posted blob to the File Asset’s datastreams and saves the File Asset.
-
#datastream_id ⇒ Object
Override this if you want to specify the datastream_id (dsID) for the created blob.
Instance Method Details
#add_posted_blob_to_asset(asset, file, file_name) ⇒ FileAsset
Puts the contents of params (posted blob) into a datastream within the given @asset Sets asset label and title to filename if they’re empty
29 30 31 32 |
# File 'lib/hydra/controller/upload_behavior.rb', line 29 def add_posted_blob_to_asset(asset, file, file_name) file_name ||= file.original_filename asset.add_file(file, datastream_id, file_name) end |
#create_and_save_file_assets_from_params ⇒ FileAsset
Creates a File Asset, adding the posted blob to the File Asset’s datastreams and saves the File Asset
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hydra/controller/upload_behavior.rb', line 6 def create_and_save_file_assets_from_params if params.has_key?(:Filedata) @file_assets = [] params[:Filedata].each do |file| @file_asset = FileAsset.new @file_asset.label = file.original_filename add_posted_blob_to_asset(@file_asset, file, file.original_filename) @file_asset.save! @file_assets << @file_asset end return @file_assets else render :text => "400 Bad Request", :status => 400 end end |
#datastream_id ⇒ Object
Override this if you want to specify the datastream_id (dsID) for the created blob
35 36 37 |
# File 'lib/hydra/controller/upload_behavior.rb', line 35 def datastream_id "content" end |