Skip to content

Commit 847d43a

Browse files
committed
add setting for expand path
1 parent b33c45b commit 847d43a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

ModuleConfig.cfc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ component {
1919
containerName : '',
2020
overwrite : false,
2121
maxDownloadRetries : 0,
22+
expandPaths : true,
2223
/*
2324
Credential Types and value option used for each:
2425

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ moduleSettings = {
7676
containerName : '',
7777
overwrite : false,
7878
maxDownloadRetries : 0,
79+
expandPaths : true,
7980
credentials : {
8081
type : 'connectionString', // connectionString, default, ClientSecret, ClientCertificate
8182
connectionString : '',

models/Client.cfc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ component accessors=true singleton ThreadSafe {
174174
* @overwrite Whether to overwrite the blob if it already exists
175175
* @timeoutSeconds The timeout for the upload operation
176176
*/
177-
function uploadBlobFromFile( required string containerName=settings.containerName, required string blobName, required string filePath, boolean overwrite=settings.overwrite, numeric timeoutSeconds=60 ) {
177+
function uploadBlobFromFile( required string containerName=settings.containerName, required string blobName, required string filePath, boolean overwrite=settings.overwrite, numeric timeoutSeconds=60, boolean expandPaths=settings.expandPaths ) {
178+
if( expandPaths ) {
179+
filePath = expandPath( filePath );
180+
}
178181
if( !overwrite && blobExists( containerName, blobName, timeoutSeconds ) ) {
179182
throw(
180183
type = "BlobStorage.BlobAlreadyExists",
@@ -184,7 +187,7 @@ component accessors=true singleton ThreadSafe {
184187

185188
var timeoutDuration = getDuration( timeoutSeconds );
186189
var blobClient = getContainerClient( containerName ).getBlobClient( blobName );
187-
var uploadOptions = createObject( 'java', 'com.azure.storage.blob.options.BlobUploadFromFileOptions' ).init( expandPath( filePath ) );
190+
var uploadOptions = createObject( 'java', 'com.azure.storage.blob.options.BlobUploadFromFileOptions' ).init( filePath );
188191
blobClient.uploadFromFileWithResponse( uploadOptions, timeoutDuration, noneContext );
189192
return this;
190193
}
@@ -222,8 +225,11 @@ component accessors=true singleton ThreadSafe {
222225
*
223226
* @return The response object containing metadata about the download operation.
224227
*/
225-
function downloadBlobToFile( required string containerName=settings.containerName, required string blobName, required string filePath, numeric timeoutSeconds=60, numeric maxDownloadRetries=settings.maxDownloadRetries, boolean overwrite=settings.overwrite ) {
226-
if( !overwrite && fileExists( expandPath( filePath ) ) ) {
228+
function downloadBlobToFile( required string containerName=settings.containerName, required string blobName, required string filePath, numeric timeoutSeconds=60, numeric maxDownloadRetries=settings.maxDownloadRetries, boolean overwrite=settings.overwrite, boolean expandPaths=settings.expandPaths ) {
229+
if( expandPaths ) {
230+
filePath = expandPath( filePath );
231+
}
232+
if( !overwrite && fileExists( filePath ) ) {
227233
throw(
228234
type = "BlobStorage.FileAlreadyExists",
229235
message = "File '#filePath#' already exists. Use overwrite=true to replace it."
@@ -234,7 +240,7 @@ component accessors=true singleton ThreadSafe {
234240

235241
var downloadOptions = // TODO: setOpenOptions(Set<OpenOption> openOptions), setParallelTransferOptions(ParallelTransferOptions parallelTransferOptions), setRange(BlobRange range), setRequestConditions(BlobRequestConditions requestConditions), setRetrieveContentRangeMd5(boolean retrieveContentRangeMd5)
236242
createObject( 'java', 'com.azure.storage.blob.options.BlobDownloadToFileOptions' )
237-
.init( expandPath( filePath ) )
243+
.init( filePath )
238244
.setDownloadRetryOptions( getDownloadRetryOptions( maxDownloadRetries ) );
239245

240246
if( arguments.overwrite ) {

0 commit comments

Comments
 (0)