问题描述
我使用 azure-storage-file-datalake对于Java在我的Azure存储帐户上进行文件系统操作,我可以打开文件,删除甚至重命名/移动文件或目录.
I use azure-storage-file-datalake for java to make file system operations on my Azure storage account, I can open files, delete, and even rename/move files or directories.
我找不到将文件/文件夹复制到其他位置的任何方法.
I can't find any way to copy files/folder to other location.
这就是我重命名/移动文件/目录的方式:
That's how I rename/move files/directories:
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复制文件或目录的其他方法?
Is there any other method I can use to copy files or directories using the azure-storage-file-datalake
SDK or even the azure-storage-blob
SDK?
推荐答案
我找到了一种使用 com.azure.storage.blob.BlobClient
在同一存储帐户中复制blob(文件)的方法.
I found a method to copy blobs(files) within the same storage account using com.azure.storage.blob.BlobClient
.
使用 beginCopy
方法如下:
using beginCopy
method as follows:
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);
这篇关于如何使用java azure-storage-file-datalake复制Azure存储文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!