Skip to content

Commit

Permalink
Merge pull request #199 from 1171736840/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
1171736840 authored Jan 12, 2024
2 parents 17e354c + c5c1883 commit 9333c29
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions x-file-storage-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-extra</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Tika -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ interface AzureBlobStorageACL extends ACL {}
* <p>又拍云 USS {@link com.upyun.RestManager.PARAMS}</p>
* <p>MinIO {@link io.minio.ObjectWriteArgs}</p>
* <p>GoogleCloud Storage {@link com.google.cloud.storage.BlobInfo} {@link com.google.cloud.storage.Storage.BlobField}</p>
* <p>FastDFS {@link org.dromara.x.file.storage.core.platform.FastDfsFileStorage#getObjectMetadata(org.dromara.x.file.storage.core.FileInfo)}</p>
* <p>Azure Blob Storage {@link com.azure.storage.blob.models.BlobHttpHeaders}</p>
*/
interface Metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.azure.storage.blob.sas.BlobServiceSasSignatureValues;
import com.azure.storage.blob.specialized.BlockBlobClient;
import com.azure.storage.file.datalake.*;
import com.azure.storage.file.datalake.models.PathAccessControl;
import com.azure.storage.file.datalake.models.PathAccessControlEntry;
import com.azure.storage.file.datalake.models.PathPermissions;
import com.azure.storage.file.datalake.models.RolePermissions;
Expand Down Expand Up @@ -252,8 +251,8 @@ public void completeMultipartUpload(CompleteMultipartUploadPretreatment pre) {
BlockBlobCommitBlockListOptions options = new BlockBlobCommitBlockListOptions(partList);
options.setMetadata(fileInfo.getUserMetadata());
options.setHeaders(getBlobHttpHeaders(fileInfo.getContentType(), fileInfo.getMetadata()));
client.commitBlockListWithResponse(options, null, Context.NONE).getValue();
setFileAcl(newFileKey, acl);
client.commitBlockListWithResponse(options, null, Context.NONE).getValue();
if (fileInfo.getSize() == null)
fileInfo.setSize(client.getProperties().getBlobSize());
} catch (Exception e) {
Expand Down Expand Up @@ -346,18 +345,18 @@ public void setFileAcl(String fileKey, AclWrapper acl) {
if (acl == null) return;
if (StrUtil.isBlank(fileKey)) return;
DataLakeFileClient fileClient = getDataLakeFileClient(fileKey);
PathAccessControl fileAccessControl = fileClient.getAccessControl();
List<PathAccessControlEntry> pathPermissions = fileAccessControl.getAccessControlList();
System.out.println(PathAccessControlEntry.serializeList(pathPermissions));
// PathAccessControl fileAccessControl = fileClient.getAccessControl();
// List<PathAccessControlEntry> pathPermissions = fileAccessControl.getAccessControlList();
// System.out.println(PathAccessControlEntry.serializeList(pathPermissions));
if (acl.getPermissions() != null) {
fileClient.setPermissions(acl.getPermissions(), null, null);
} else if (acl.getAclList() != null) {
fileClient.setAccessControlList(acl.getAclList(), null, null);
} else {
throw new NullPointerException();
}
pathPermissions = fileClient.getAccessControl().getAccessControlList();
System.out.println(PathAccessControlEntry.serializeList(pathPermissions));
// pathPermissions = fileClient.getAccessControl().getAccessControlList();
// System.out.println(PathAccessControlEntry.serializeList(pathPermissions));
}

@Override
Expand Down Expand Up @@ -517,8 +516,12 @@ public void sameCopy(FileInfo srcFileInfo, FileInfo destFileInfo, CopyPretreatme
destFileInfo.setThUrl(getUrl(destThFileKey));
try {
awaitCopy(destThClient.beginCopy(srcThClient.getBlobUrl(), Duration.ofSeconds(1)));

setFileAcl(destThFileKey, getAcl(srcFileInfo.getThFileAcl()));
} catch (Exception e) {
try {
destThClient.deleteIfExists();
} catch (Exception ignored) {
}
throw ExceptionFactory.sameCopyTh(srcFileInfo, destFileInfo, platform, e);
}
}
Expand All @@ -529,6 +532,7 @@ public void sameCopy(FileInfo srcFileInfo, FileInfo destFileInfo, CopyPretreatme
long size = srcClient.getProperties().getBlobSize();
ProgressListener.quickStart(pre.getProgressListener(), size);
awaitCopy(destClient.beginCopy(srcClient.getBlobUrl(), Duration.ofSeconds(1)));
setFileAcl(destFileKey, getAcl(srcFileInfo.getFileAcl()));
ProgressListener.quickFinish(pre.getProgressListener(), size);
} catch (Exception e) {
if (destThClient != null)
Expand Down

0 comments on commit 9333c29

Please sign in to comment.