java - 如何使用 java azure-storage-file-datalake 复制 Azure 存储文件/目录
问题描述
我使用azure-storage-file-datalake for java 在我的 Azure 存储帐户上进行文件系统操作,我可以打开文件、删除甚至重命名/移动文件或目录。
我找不到将文件/文件夹复制到其他位置的任何方法。
这就是我重命名/移动文件/目录的方式:
DataLakeServiceClient storageClient = new DataLakeServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient();
DataLakeFileSystemClient dataLakeFileSystemClient = storageClient.getFileSystemClient("storage");
DataLakeFileClient fileClient = dataLakeFileSystemClient.getFileClient("src/path");
fileClient.rename("storage", "dest/path");
有没有其他方法可以使用azure-storage-file-datalake
SDK 甚至azure-storage-blob
SDK 来复制文件或目录?
解决方案
我找到了一种使用com.azure.storage.blob.BlobClient
.
使用beginCopy
方法如下:
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint(spnEndpoint).credential(credential).buildClient();
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient("containerName");
BlobClient dst = blobContainerClient.getBlobClient("destination/blob");
BlobClient src = blobContainerClient.getBlobClient("src/blob");
dst.beginCopy(src.getBlobUrl(), null);
推荐阅读
- regex - 使用 Regex 检测最新的直接下载链接 URL,从而使用 AHK 或其他脚本语言快速 DL 最新软件
- django - 如何将用户选择的日期时间转换为毫秒
- bash - Shell 命令手动工作,不使用 Ansible
- batch-file - 如何将批处理文件中的变量传递到任务调度程序
- reactjs - 无法读取未定义的属性“数组”
- swift - google ios SDK 快速适应用户位置和选定标记位置的界限
- json - Swift - 从 Firebase 读取数据(实时数据库)
- sql - 如何在 SQL Server 中使用正则表达式检查字符串是否为数字?
- html - 难以处理的 iframe 嵌入 - 不能很好地播放
- linux - 如何运行将停止当前进程的shell?