UploadCare迁移工具
uploadcare-migro的Python项目详细描述
migro帮助您从其他云文件管理迁移到uploadcare 像filestack、cloudinary等服务。 目前,我们支持从filestack迁移,但是您可以迁移 从其他服务:你只需要提供你的文件网址导入。
安装
此实用程序需要Python3.5.3或更高版本。
要安装migro,只需运行:
$ pip install uploadcare-migro
用法
$ migro <PUBLIC_KEY> <INPUT_FILE>
其中:
<PUBLIC_KEY>-你的uploadcare项目public key。
<INPUT_FILE>-包含文件url列表的文本文件 上传到UploadCare项目。
其他选项:
-v, --version Show utility version and quit. -h, --help Show this help and quit. --output_file FILE Path to a Migro output file. [default: migro_result.txt] --upload_base TEXT Base URL for uploads. [default: https://upload.uploadcare.com/] --from_url_timeout FLOAT Number of seconds to wait till the file will be processed by `from_url` upload. [default: 30] --max_uploads INTEGER Maximum number of upload requests running in 'parallel'. [default: 20] --check_interval FLOAT Number of seconds in between status check requests.
输出文件格式
输出文件格式非常简单。 对于每个输入文件url或filestack文件句柄,有3列除以t符号(tab)。
第一列保存输入文件url或filestack句柄本身, 第二列-上传操作状态:成功或失败, 第三列-输出UploadCare URL或错误描述。
例如,您愿意将以下三个文件迁移到uploadcare 其中前两个显示为url,第三个显示为filestack文件 把手。此外,这也是您的输入文本文件的结构:
https://cdn.filestackcontent.com/YBLVVdUpRqC4nOynxDd8 https://www.facebook.com/rsrc.php/v3/y7/r/dTQOHZm7Z-3.svg uNWvPRXJQmO49MJbPZn9
这就是您在migro输出文件中获得的输入项:
https://cdn.filestackcontent.com/YBLVVdUpRqC4nOynxDd8 success https://ucarecdn.com/d8f8de4b-f92e-41a0-b7f9-28fd4baad9ae/ https://www.facebook.com/rsrc.php/v3/y7/r/dTQOHZm7Z-3.svg success https://ucarecdn.com/4a03f3d4-2bd3-456e-89a5-008190980248/ https://cdn.filestackcontent.com/uNWvPRXJQmO49MJbPZn9 fail Uploading of these files types is not allowed on your current plan.
迁移工作原理
迁移本身相当简单:您提供了一个文件url列表 或者filestack文件处理程序,这些文件会上传到uploadcare 项目。就这样。 Migro不下载任何文件。它利用了 Uploading API。 具体来说,它使用From URLmethod。
结果,您将得到所有上传文件的列表。 对于每个处理过的文件,你也会得到它的状态和错误, 以防万一。
示例
下面是如何运行实用程序:
$ migro 9a598e2a47fe961ea412 fileslist.txt --output_file /tmp/migro-result.txt
这就是你得到的:
Upload progress: 100%|████████████████████████████████████████████████| 6/6 [00:03<00:00, 1.74s/file] All files have been processed, output URLs were written to: are here: /tmp/migro_result.txt Number of failed files: 1 Thanks for your interest in Uploadcare. Hit us up at help@uploadcare.com in case of any questions.
Windows用户的注意事项
目前windows上的ctrl+c终止程序有问题,所以 用这种方法不能正确终止程序。
这是一个依赖于平台的python编程语言问题。
备选方案
你可以用我们的libs 从任何源迁移文件。