class SafeDb::Read

The read use case pulls a file in from either an accessible filesystem.

This use case expects a @file_url parameter.

Attributes

file_key[W]
file_url[W]

Public Instance Methods

edit_verse() click to toggle source

The read use case pulls a file in from an accessible filesystem.

# File lib/controller/files/read.rb, line 13
def edit_verse()

  file_full_path = ::File.absolute_path( @file_url )
  file_base_name = ::File.basename( file_full_path )
  file_content64 = Base64.urlsafe_encode64( ::File.read( file_full_path ) )

  log.info(x) { "Key name of the file to ingest => #{@file_key}" }
  log.info(x) { "Ingesting file at path => #{file_full_path}" }
  log.info(x) { "The name of the file to ingest is => #{file_base_name}" }
  log.info(x) { "Size of base64 file content => [#{file_content64.length}]" }

  filedata_map = {}
  filedata_map.store( Indices::INGESTED_FILE_BASE_NAME_KEY, file_base_name )
  filedata_map.store( Indices::INGESTED_FILE_CONTENT64_KEY, file_content64 )

  @verse.store( Indices::INGESTED_FILE_LINE_NAME_KEY + @file_key, filedata_map )

end