|
|
@ -46,7 +46,6 @@ import java.nio.file.Files; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -76,7 +75,6 @@ import com.amazonaws.services.s3.model.S3ObjectSummary; |
|
|
|
import com.amazonaws.services.s3.transfer.MultipleFileDownload; |
|
|
|
import com.amazonaws.services.s3.transfer.MultipleFileDownload; |
|
|
|
import com.amazonaws.services.s3.transfer.TransferManager; |
|
|
|
import com.amazonaws.services.s3.transfer.TransferManager; |
|
|
|
import com.amazonaws.services.s3.transfer.TransferManagerBuilder; |
|
|
|
import com.amazonaws.services.s3.transfer.TransferManagerBuilder; |
|
|
|
import com.google.common.base.Joiner; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
@Data |
|
|
|
@Data |
|
|
@ -182,7 +180,7 @@ public class S3StorageOperator implements Closeable, StorageOperate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getResourceFileName(String tenantCode, String fileName) { |
|
|
|
public String getResourceFullName(String tenantCode, String fileName) { |
|
|
|
if (fileName.startsWith(FOLDER_SEPARATOR)) { |
|
|
|
if (fileName.startsWith(FOLDER_SEPARATOR)) { |
|
|
|
fileName = fileName.replaceFirst(FOLDER_SEPARATOR, ""); |
|
|
|
fileName = fileName.replaceFirst(FOLDER_SEPARATOR, ""); |
|
|
|
} |
|
|
|
} |
|
|
@ -190,23 +188,9 @@ public class S3StorageOperator implements Closeable, StorageOperate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getResourceFileName(String fullName) { |
|
|
|
public String getResourceFileName(String tenantCode, String fullName) { |
|
|
|
// here is a quick fix here to get fileName. We get the resource upload path and
|
|
|
|
String resDir = getResDir(tenantCode); |
|
|
|
// get the index of the first appearance of resource upload path. The index is put
|
|
|
|
return fullName.replaceFirst(resDir, ""); |
|
|
|
// in the start index of the substring function and get the result substring containing
|
|
|
|
|
|
|
|
// tenantcode and "resource" directory and the fileName.
|
|
|
|
|
|
|
|
// Then we split the result substring
|
|
|
|
|
|
|
|
// with "/" and join all elements except the first two elements because they are
|
|
|
|
|
|
|
|
// tenantCode and "resource" directory.
|
|
|
|
|
|
|
|
String resourceUploadPath = |
|
|
|
|
|
|
|
RESOURCE_UPLOAD_PATH.endsWith(FOLDER_SEPARATOR) ? StringUtils.chop(RESOURCE_UPLOAD_PATH) |
|
|
|
|
|
|
|
: RESOURCE_UPLOAD_PATH; |
|
|
|
|
|
|
|
// +1 because we want to skip the "/" after resource upload path as well.
|
|
|
|
|
|
|
|
String pathContainingTenantNResource = fullName.substring( |
|
|
|
|
|
|
|
fullName.indexOf(resourceUploadPath) |
|
|
|
|
|
|
|
+ resourceUploadPath.length() + 1); |
|
|
|
|
|
|
|
String[] fileNameArr = pathContainingTenantNResource.split(FOLDER_SEPARATOR); |
|
|
|
|
|
|
|
return Joiner.on(FOLDER_SEPARATOR).join(Arrays.stream(fileNameArr).skip(2).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|