Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以复制azure blob文件夹而不遍历每个blob文件吗?_Azure_Go_Azure Storage_Azure Storage Blobs - Fatal编程技术网

我可以复制azure blob文件夹而不遍历每个blob文件吗?

我可以复制azure blob文件夹而不遍历每个blob文件吗?,azure,go,azure-storage,azure-storage-blobs,Azure,Go,Azure Storage,Azure Storage Blobs,目前我使用golang实现将文件从一个存储帐户复制到另一个存储帐户 例如: https://storage1.blob.core.windows.net/container/A/B/file1.mp4 https://storage1.blob.core.windows.net/container/A/B/file2.mp4 https://storage1.blob.core.windows.net/container/A/B/file3.mp4 Copy from https://st

目前我使用golang实现将文件从一个存储帐户复制到另一个存储帐户

例如:

https://storage1.blob.core.windows.net/container/A/B/file1.mp4
https://storage1.blob.core.windows.net/container/A/B/file2.mp4
https://storage1.blob.core.windows.net/container/A/B/file3.mp4


Copy from

https://storage1.blob.core.windows.net/container/A/B/
to 
https://storage2.blob.core.windows.net/container/A/B/
我可以复制整个文件夹而不遍历文件夹A/B中的所有文件吗

这是我的示例代码


func(css StorageOperator)nestedListBlob(ctx context.context,srcFolderPath字符串)([]azblob.BlobURL,错误){
containerName,folderPath:=css.GetContainerNamedPath(srcFolderPath)
containerRawUrl:=“https://”+css.StorageName+“+lib.AzureBlobUrl+”/“+containerName”
containerUrl,:=url.Parse(containerRawUrl)
po:=azblob.NewPipeline(css.sharedKeyCredential,css.createPipelineOptions())
容器:=azblob.NewContainerURL(*containerUrl,po)
var blobUrls[]azblob.BlobURL
//列出容器中的blob;由于容器可能包含数百万个blob,因此每次只需执行一段。
对于marker:=(azblob.marker{});marker.NotDone(){
//需要标记{}周围的参数以避免编译器错误。
//获取以当前标记指示的blob开始的结果段。
listBlob,err:=container.ListBlobsFlatSegment(ctx,marker,azblob.ListBlobsSegmentOptions{
前缀:folderPath,
})
如果错误!=零{
返回零,错误
}
//要点:ListBlobs返回下一段的开头;您必须使用它来获取
//下一段(处理当前结果段后)。
marker=listBlob.NextMarker
//处理此结果段中返回的blob(如果该段为空,则不会执行循环体)
对于,blobInfo:=范围列表blob.Segment.BlobItems{
Debugf(“Blob名称:“+containerRawUrl+”/“+blobInfo.name”)
blobUrl,:=url.Parse(containerRawUrl+“/”+blobInfo.Name)
blobUrls=append(blobUrls,azblob.NewBlobURL(*blobUrl,po))
}
}
返回blobUrls,零
}
func(css StorageOperator)parallelCopyFileToDst(ctx context.context,po pipeline.pipeline,dstRawUrl字符串,srcBlobs[]azblob.BlobURL)错误{
对于,srcBlob:=范围srcBlob{
dstUrl,932;:=url.Parse(dstRawUrl+css.extractBlobPath(srcBlob))
dstBlobURL:=azblob.NewBlobURL(*dstUrl,po)
srcSASUrl,err:=css.createSASURL(css.lukeSharedKeyCredential,srcBlob.String())
如果错误!=零{
Errorf(“createSASURL失败:%v”,错误)
返回
}
startCopy,err:=dstBlobURL.StartCopyFromURL(ctx,
*srcSASUrl,
azblob.Metadata{},
azblob.ModifiedAccessConditions{},
azblob.BlobAccessConditions{})
如果错误!=零{
css.logger.Errorf(“startCopy失败:%v”,错误)
返回
}
如果err=css.checkCopyStatus(ctx、dstBlobURL、startCopy);err!=nil{
css.logger.Errorf(“checkCopyStatus失败:%v”,错误)
返回
}
}//为了
归零
}

azure blobs中不存在文件夹结构,而是使用路径名,因此如果要在“虚拟文件夹”中复制blobs,只需使用路径即可,下面是python中列出blobs的示例:

  ['Virtual-Folder/Boards.png', 'storage2.gif']

因此,为了传输Boards.png blob,您必须在其前面附加文件夹名,而不是查看文件夹内的内容。我用python编写了一些关于这个示例/问题的教程:

afaik容器级别下没有真正的文件夹。文件夹只是名称和路径的一部分。您可以使用azcopy吗<代码>azcopy同步“https://[account].blob.core.windows.net/[container]/[path/to/virtual/dir]?[SAS]“https://[account].blob.core.windows.net/[container]/[path/to/virtual/dir]”--recursive=trueFrom:@slient但我想通过程序控制,我知道我可以用AZCOPY来控制cmd。请分享你写的任何代码。我不明白你的意思?现在我按完整路径(包括虚拟路径)复制blob,但我想知道是否有任何方法可以只按虚拟文件夹复制而不遍历此虚拟文件夹中的所有blob。不是真的,不是按虚拟文件夹,只是按路径