Mighten commented on code in PR #16565:
URL: 
https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769532967


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements 
Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 
1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, 
secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {

Review Comment:
   The `File.separator` works poorly on Windows 11 x64.
   
   ![Screenshot 2024-09-21 
184343](https://github.com/user-attachments/assets/e53415c7-1afb-4cfe-be99-225bf36ae793)
   
   - When the user successfully uploads the "test.log" file, there is no way to 
enter the deeper directory to view the file.
   - When the user tries to delete the folder, an exception is thrown stating 
that the folder does not exist.
   
   So, for now, I think we should continue using the UNIX filesystem separator 
("/"), just like the already existing code, until a **DSIP** for *Windows 
platform compatibility* is provided.
   
   
![existing-unix-like-file-separator-codes](https://github.com/user-attachments/assets/2bbd6cbf-c67b-4bfe-8c5f-098bbb601a16)
   
   
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to