Sha256: 02d711e7a1018b7cf1f62c3a696673b1d005e1c8e4944019eb1b3813be1cb4a8

Contents?: true

Size: 538 Bytes

Versions: 5

Compression:

Stored size: 538 Bytes

Contents

module BulutfonSDK
  module Util
    def file_content_type(path)
      if File.exist? path
        stdin,stdout,stderr = Open3.popen3(%{file --mime -b #{path}})

        file_err  = stderr.gets
        file_out  = stdout.gets

        raise BulutfonSDK::REST::SDKError.new "The 'file' command line binary was not found." if file_err

        return file_out.split(';')[0].strip if file_err.nil? && (!file_out.nil? && !file_out.empty?)
      end

      raise BulutfonSDK::REST::SDKError.new 'File content type not found'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bulutfon_sdk-1.3.0 lib/bulutfon_sdk/util.rb
bulutfon_sdk-1.2.1 lib/bulutfon_sdk/util.rb
bulutfon_sdk-1.2.0 lib/bulutfon_sdk/util.rb
bulutfon_sdk-1.1.3 lib/bulutfon_sdk/util.rb
bulutfon_sdk-1.1.0 lib/bulutfon_sdk/util.rb