如何将文件从本地计算机传输到 Azure 容器中的虚拟文件夹(使用 blobxfer)
How to transfer files from local machine to virtual folders within an Azure container (using blobxfer)
我正在使用 blobxfer 将一些文件上传到 Azure 存储。它类似于 AzCopy,但用于 Linux OS(而 AzCopy 用于 Windows)。
基本上,我在 /home/myuser/s3/
位置有两个文件夹。一个文件夹名为 /uploads/
,另一个文件夹名为 /users/
。这些文件夹包含大量图像文件。我需要将这两个文件夹上传到 Azure 容器。
请记住,我不希望文件夹的内容在 Azure 存储上混合,它们需要传输到我的 Azure 容器中的单独虚拟文件夹。例如,我有一个名为 pictures
的容器,我希望 /s3/uploads/
(本地文件夹)的内容驻留在 pictures
容器中的虚拟文件夹 /uploads/
中。 /s3/users/
也是如此。
这些虚拟文件夹已经存在于我的容器中。我从命令行尝试的命令是:
blobxfer mystorageaccount pictures /home/myuser/s3 --upload --storageaccountkey=<primary access key from portal.azure.com> --no-container
失败并出现 未知错误(HTTP headers 之一的值格式不正确。)。完整的追溯是:
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
RequestId:61a1486c-0101-00d6-13b5-408578134000
Time:2015-12-27T12:56:03.5390180Z</Message><HeaderName>x-ms-blob-content-length</HeaderName><HeaderValue>0</HeaderValue></Error>
Exception in thread Thread-49 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/home/myuser/.virtualenvs/redditpk/local/lib/python2.7/site-packages/blobxfer.py", line 506, in run
File "/home/myuser/.virtualenvs/redditpk/local/lib/python2.7/site-packages/blobxfer.py", line 597, in putblobdata
File "/home/myuser/.virtualenvs/redditpk/local/lib/python2.7/site-packages/blobxfer.py", line 652, in azure_request
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Timeout'
我做错了什么,我该如何解决?
查看错误,很明显脚本正在尝试创建容器(pictures
在您的情况下)但是容器已经存在。
我快速查找了 Github 上的代码,似乎有一个名为 createcontainer
的参数。此参数的默认值为 True
。尝试在您的脚本中传递此参数并将其值初始化为 False
。那么脚本不应尝试创建容器。
如您在其他 中所述,直接问题是 zero-byte 文件。围绕这些文件的一些错误已在最近发布的 blobxfer 0.9.9.6 中得到修复。如果最新版本没有解决您看到的错误,请使用项目的 GitHub 问题页面。
另一个问题是您想将父目录中的子目录上传到同一个容器。如果这两个目录是父目录中的唯一目录,那么您可以使用 blobxfer 的一次调用来实现您想要的。否则,您将需要两次单独调用 blobxfer(每个子目录一次)。在任何一种情况下,因为您使用的是绝对路径,您都需要指定 --strip-components
参数(类似于同名的 tar
参数),以便它们可以很好地嵌套在带有 [= 的容器下23=] 你想要的目录。如果您使用相对基本路径,那么您将不需要 --strip-components
参数,例如,从 /home/myuser
中调用 blobxfer 并将您的本地资源指定为 s3
.
关于容器已经存在的问题,如果容器已经存在应该没有问题。它会忽略这样的失败。
我正在使用 blobxfer 将一些文件上传到 Azure 存储。它类似于 AzCopy,但用于 Linux OS(而 AzCopy 用于 Windows)。
基本上,我在 /home/myuser/s3/
位置有两个文件夹。一个文件夹名为 /uploads/
,另一个文件夹名为 /users/
。这些文件夹包含大量图像文件。我需要将这两个文件夹上传到 Azure 容器。
请记住,我不希望文件夹的内容在 Azure 存储上混合,它们需要传输到我的 Azure 容器中的单独虚拟文件夹。例如,我有一个名为 pictures
的容器,我希望 /s3/uploads/
(本地文件夹)的内容驻留在 pictures
容器中的虚拟文件夹 /uploads/
中。 /s3/users/
也是如此。
这些虚拟文件夹已经存在于我的容器中。我从命令行尝试的命令是:
blobxfer mystorageaccount pictures /home/myuser/s3 --upload --storageaccountkey=<primary access key from portal.azure.com> --no-container
失败并出现 未知错误(HTTP headers 之一的值格式不正确。)。完整的追溯是:
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
RequestId:61a1486c-0101-00d6-13b5-408578134000
Time:2015-12-27T12:56:03.5390180Z</Message><HeaderName>x-ms-blob-content-length</HeaderName><HeaderValue>0</HeaderValue></Error>
Exception in thread Thread-49 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/home/myuser/.virtualenvs/redditpk/local/lib/python2.7/site-packages/blobxfer.py", line 506, in run
File "/home/myuser/.virtualenvs/redditpk/local/lib/python2.7/site-packages/blobxfer.py", line 597, in putblobdata
File "/home/myuser/.virtualenvs/redditpk/local/lib/python2.7/site-packages/blobxfer.py", line 652, in azure_request
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Timeout'
我做错了什么,我该如何解决?
查看错误,很明显脚本正在尝试创建容器(pictures
在您的情况下)但是容器已经存在。
我快速查找了 Github 上的代码,似乎有一个名为 createcontainer
的参数。此参数的默认值为 True
。尝试在您的脚本中传递此参数并将其值初始化为 False
。那么脚本不应尝试创建容器。
如您在其他
另一个问题是您想将父目录中的子目录上传到同一个容器。如果这两个目录是父目录中的唯一目录,那么您可以使用 blobxfer 的一次调用来实现您想要的。否则,您将需要两次单独调用 blobxfer(每个子目录一次)。在任何一种情况下,因为您使用的是绝对路径,您都需要指定 --strip-components
参数(类似于同名的 tar
参数),以便它们可以很好地嵌套在带有 [= 的容器下23=] 你想要的目录。如果您使用相对基本路径,那么您将不需要 --strip-components
参数,例如,从 /home/myuser
中调用 blobxfer 并将您的本地资源指定为 s3
.
关于容器已经存在的问题,如果容器已经存在应该没有问题。它会忽略这样的失败。