Method: COS::COSFile#download

Defined in:
lib/cos/file.rb

#download(file_store, options = {}) {|Float| ... } ⇒ String

下载当前文件, 支持断点续传, 支持多线程

Parameters:

  • file_store (String)

    本地文件存储路径

  • options (Hash) (defaults to: {})

    高级参数

Options Hash (options):

  • :min_slice_size (Integer)

    完整下载最小文件大小, 超过此大小将会使用分片多线程断点续传

  • :download_retry (Integer)

    下载重试次数, 默认10

  • :disable_cpt (Boolean)

    是否禁用checkpoint功能,如果设置为true,则在下载的过程中不会写checkpoint文件,这意味着下载失败后不能断点续传,而只能重新下载整个文件。如果这个值为true,则:cpt_file会被忽略。

  • :threads (Integer)

    多线程下载线程数, 默认为10

  • :slice_size (Integer)

    设置分片下载时每个分片的大小默认为5 MB。

  • :cpt_file (String)

    断点续传的checkpoint文件,如果指定的cpt文件不存在,则会在file所在目录创建一个默认的cpt文件,命名方式为:file.cpt,其中file是用户要下载的文件名。在下载的过程中会不断更新此文件,成功完成下载后会删除此文件;如果指定的cpt文件已存在,则从cpt文件中记录的点继续下载。

Yields:

  • (Float)

    下载进度百分比回调, 进度值是一个0-1之间的小数

Returns:

  • (String)

Raises:

See Also:



131
132
133
# File 'lib/cos/file.rb', line 131

def download(file_store, options = {}, &block)
  bucket.download(self, file_store, options, &block)
end