[英]How to copy files from Azure File-Share (not blob) of different storage account using .net core
public void MoveFiles(AzureFileClient srcAzureClient, AzureFileClient destAzureClient, ShareClient srcShareClient, ShareClient destShareClient, string dirName)
{
if (!destAzureClient.ShareClient.GetDirectoryClient(dirName).Exists())
destAzureClient.ShareClient.GetDirectoryClient(dirName).Create();
var fileItems = GetChildNodes(srcShareClient, dirName);
if (fileItems.Count == 0)
return;
foreach (var item in fileItems)
{
if (item.ShareFileItem.IsDirectory)
{
MoveFiles(srcAzureClient, destAzureClient, srcShareClient, destShareClient, $"{dirName}/{item.ShareFileItem.Name}");
}
else
{
var srcFileClient = srcShareClient.GetDirectoryClient(Path.GetDirectoryName(item.FullPath)).GetFileClient(Path.GetFileName(item.FullPath));
var destFileClient = destShareClient.GetDirectoryClient(Path.GetDirectoryName(item.FullPath)).GetFileClient(Path.GetFileName(item.FullPath));
if (srcFileClient.Exists())
{
destFileClient.StartCopy(srcFileClient.Uri);
}
}
}
}
This code is throwing an error at此代码在
destFileClient.StartCopy(srcFileClient.Uri)
saying说
sourceCopy is not verified, connection strings are given to both source & destination fileShare object sourceCopy 未验证,连接字符串提供给源和目标文件共享 object
I am able to copy files from the same account storage.我能够从同一个帐户存储复制文件。
When copying files (or blobs) across storage accounts, the source file (or blob) must be publicly accessible.跨存储帐户复制文件(或 blob)时,源文件(或 blob)必须可公开访问。 This restriction does not apply when the source and destination are in the same storage account.当源和目标位于同一存储帐户中时,此限制不适用。
Because Azure Files are inherently private (there's no concept of ACL like we have in Blob Storage), you are getting this error as Azure Storage Service is not able to read the source file.因为 Azure 文件本质上是私有的(没有像我们在 Blob 存储中那样的 ACL 的概念),您会收到此错误,因为 Azure 存储服务无法读取源文件。
To fix this, you would need to create a SAS URL with at least read permission on the source file and use that SAS URL as copy source. To fix this, you would need to create a SAS URL with at least read permission on the source file and use that SAS URL as copy source.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.