Action-AzureBlobUpload icon indicating copy to clipboard operation
Action-AzureBlobUpload copied to clipboard

Question: Is it possible to rename the file on upload

Open LiamDHall opened this issue 1 year ago • 1 comments

so I have an image i want to upload but the source image will not conform to the naming requirement used by the application that in the end will be looking for.

Is it possible to rename the file on upload

LiamDHall avatar Apr 25 '24 13:04 LiamDHall

Hi @LiamDHall

This is an interesting situation that hasn't come up yet, because usually the file is available to be renamed before the upload step.

It's as easy as this single command Rename-Item -NewName {$_.name -replace 'original', 'replacement'}, so you can put it directly before the upoad step.

Tor example, let's say I want to replace - with an _ in all my .png file names.

- name: Change filename dashes to underscores
  run: |
    Get-ChildItem "/MyFolderToUpload" -Recurse -Filter "*.png" | Rename-Item -NewName {$_.name -replace '-', '_'}
  
- name: Uploading Files to Azure Blob
  id: sideload-blob-upload
  uses: LanceMcCarthy/Action-AzureBlobUpload@v3
  with:
    connection_string: "${{ secrets.AZURE_DVLUP_BLOB_CONNECTION_STRING }}"
    container_name: general-app-files
    source_folder: "/MyFolderToUpload"
    destination_folder: "MyUploadedStuff"
    clean_destination_folder: true
    is_recursive: true
    delete_if_exists: true

I'll see about possible adding this feature to the upload action, I'll need to be extra careful not to break anyone else in the process though.

LanceMcCarthy avatar Apr 25 '24 17:04 LanceMcCarthy