Class: LibStorj::Ext::Storj::UploadOptions
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- LibStorj::Ext::Storj::UploadOptions
- Defined in:
- lib/ruby-libstorj/ext/upload_options.rb
Instance Method Summary collapse
-
#initialize(bucket_id:, file_path:, file_name: nil, index: nil) ⇒ UploadOptions
constructor
A new instance of UploadOptions.
Constructor Details
#initialize(bucket_id:, file_path:, file_name: nil, index: nil) ⇒ UploadOptions
Returns a new instance of UploadOptions.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby-libstorj/ext/upload_options.rb', line 14 def initialize(bucket_id:, file_path:, file_name: nil, index: nil) if file_path.nil? || !::File.exists?(file_path) raise Errno::ENOENT.new(file_path || 'nil') end file_name = ::File.basename(file_path) if !file_name super() self[:prepare_frame_limit] = 1 self[:push_frame_limit] = 64 self[:push_shard_limit] = 64 self[:rs] = true self[:index] = (index.is_a?(String) && index.length == 64) ? index : FFI::MemoryPointer::NULL self[:bucket_id] = FFI::MemoryPointer.from_string bucket_id self[:file_name] = FFI::MemoryPointer.from_string file_name self[:fd] = ::LibStorj::Ext::LibC.fopen file_path, 'r' end |