app/models/ss/streaming_file.rb
# not implemented save_file for grid-fs mode
not implemented save_file for grid-fs mode
not implemented save_file for grid - fs mode
def save_file
    return if in_remote_url.blank?
    Fs.mkdir_p(::File.dirname(path))
    content_type = nil
    size_limit = in_size_limit.to_i
    start_fetch(in_remote_url, 10, {}) do |response|
      overall_received_bytes = 0
      content_type = response.content_type
      content_length = response.content_length.to_i
      if size_limit > 0 && content_length > 0 && content_length > size_limit
        raise SS::StreamingFile::SizeError, "file size limit exceeded"
      end
      ::File.open(path, "wb") do |f|
        response.read_body do |chunk|
          if size_limit > 0 && overall_received_bytes > size_limit
            raise SS::StreamingFile::SizeError, "file size limit exceeded"
          end
          f.write chunk
          overall_received_bytes += chunk.size
          print number_to_human_size(overall_received_bytes), " " * 10, "\r"
        end
      end
    end
    self.content_type = ::SS::MimeType.find(filename, content_type)
    self.size = Fs.stat(path).size
  end
def save_file return if in_remote_url . blank? Fs . mkdir_p ( :: File . dirname ( path ) ) content_type = nil size_limit = in_size_limit . to_i start_fetch ( in_remote_url , 10 , { } ) do | response | overall_received_bytes = 0 content_type = response . content_type content_length = response . content_length . to_i if size_limit > 0 && content_length > 0 && content_length > size_limit raise SS :: StreamingFile :: SizeError , "file size limit exceeded" end :: File . open ( path , "wb" ) do | f | response . read_body do | chunk | if size_limit > 0 && overall_received_bytes > size_limit raise SS :: StreamingFile :: SizeError , "file size limit exceeded" end f . write chunk overall_received_bytes += chunk . size print number_to_human_size ( overall_received_bytes ) , " " * 10 , "\r" end end end self . content_type = :: SS :: MimeType . find ( filename , content_type ) self . size = Fs . stat ( path ) . size end
not implemented save_file for grid-fs mode
not implemented save_file for grid - fs mode
# TODO: do some exif things