Skip to content

Commit

Permalink
LPD-36650 In LPD-34342 (d8ee37e), azure bom was upgraded from 1.2.20 …
Browse files Browse the repository at this point in the history
…to 1.2.26. azure-storage-blob version was upgraded from 12.25.1 to 12.27.0. In 12.26.0, there is a breaking change about URLEncoding the blob names. See: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/CHANGELOG.md

BlobContainerClient.getBlobClient(String blobName) method no longer require us to do url encoding before we pass it in.
  • Loading branch information
julschong authored and brianchandotcom committed Sep 19, 2024
1 parent c92f6d9 commit 86044b1
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.azure.storage.blob.models.BlobItem;
import com.azure.storage.blob.models.BlobProperties;
import com.azure.storage.blob.models.ListBlobsOptions;
import com.azure.storage.common.Utility;

import com.liferay.document.library.kernel.exception.NoSuchFileException;
import com.liferay.document.library.kernel.store.Store;
Expand Down Expand Up @@ -78,7 +77,7 @@ public void addFile(
throws PortalException {

BlobClient blobClient = _blobContainerClient.getBlobClient(
_getBlobItemName(companyId, repositoryId, fileName, versionLabel));
_getAzurePath(companyId, repositoryId, fileName, versionLabel));

File tempFile = null;

Expand Down Expand Up @@ -158,7 +157,7 @@ public void deleteFile(
String versionLabel) {

BlobClient blobClient = _blobContainerClient.getBlobClient(
_getBlobItemName(companyId, repositoryId, fileName, versionLabel));
_getAzurePath(companyId, repositoryId, fileName, versionLabel));

if (blobClient.exists()) {
blobClient.delete();
Expand All @@ -177,7 +176,7 @@ public InputStream getFileAsStream(
}

BlobClient blobClient = _blobContainerClient.getBlobClient(
_getBlobItemName(companyId, repositoryId, fileName, versionLabel));
_getAzurePath(companyId, repositoryId, fileName, versionLabel));

if (!blobClient.exists()) {
throw new NoSuchFileException(
Expand Down Expand Up @@ -220,7 +219,7 @@ public long getFileSize(
}

BlobClient blobClient = _blobContainerClient.getBlobClient(
_getBlobItemName(companyId, repositoryId, fileName, versionLabel));
_getAzurePath(companyId, repositoryId, fileName, versionLabel));

if (!blobClient.exists()) {
throw new NoSuchFileException(
Expand Down Expand Up @@ -281,7 +280,7 @@ public boolean hasFile(
}

BlobClient blobClient = _blobContainerClient.getBlobClient(
_getBlobItemName(companyId, repositoryId, fileName, versionLabel));
_getAzurePath(companyId, repositoryId, fileName, versionLabel));

return blobClient.exists();
}
Expand Down Expand Up @@ -375,14 +374,6 @@ private String _getAzurePath(
return sb.toString();
}

private String _getBlobItemName(
long companyId, long repositoryId, String fileName,
String versionLabel) {

return Utility.urlEncode(
_getAzurePath(companyId, repositoryId, fileName, versionLabel));
}

private String _getFileName(
long companyId, long repositoryId, String blobItemName) {

Expand Down

0 comments on commit 86044b1

Please sign in to comment.