Skip to content

Conversation

@sujata-m
Copy link
Contributor

@sujata-m sujata-m commented Sep 24, 2025

  • Updated the Azure file upload flow to pass overwrite=True so existing blobs are replaced when uploading and the remote
  • URL remains captured. Adjusted the Azure file entity unit test to assert that the overwrite flag is supplied to upload_blob.
  • Updated the abstract FileEntity.upload signature to accept an optional overwrite flag so every storage provider exposes the same interface.
  • Adjusted the local file entity’s upload method to accept the new flag while keeping its upload behavior unchanged.

Tests -

With override

from python_ms_core import Core
from io import BytesIO, StringIO

core = Core()

azure_client = core.get_storage_client()

container = azure_client.get_container(container_name='tdei-storage-test')
txt = 'foo\nbar\nbaz'
file_like_io = StringIO(txt)
filename = 'sample-file'

try:
    test_file container.create_file(f'{filename}.txt')
except Exception as e:
    print(e)

try:
    test_file.upload(file_like_io.read(), override=True)
    print(test_file.get_remote_url())
    print('Uploaded Successfully')
except Exception as e:
    print(f'Request failed with Code: {e.status_code}, Message: {e.message}')
    

Output

https://tdeisamplestorage.blob.core.windows.net/tdei-storage-test/sample-file_test.txt
Uploaded Successfully

Without override

from python_ms_core import Core
from io import BytesIO, StringIO

core = Core()

azure_client = core.get_storage_client()

container = azure_client.get_container(container_name='tdei-storage-test')
txt = 'foo\nbar\nbaz'
file_like_io = StringIO(txt)
filename = 'sample-file'

try:
    test_file container.create_file(f'{filename}.txt')
except Exception as e:
    print(e)

try:
    test_file.upload(file_like_io.read())
    print(test_file.get_remote_url())
    print('Uploaded Successfully')
except Exception as e:
    print(f'Request failed with Code: {e.status_code}, Message: {e.message}')
    

Output

Request failed with Code: 422, Message: Http Response Error: The specified blob already exists.

Updated the Azure file upload flow to pass overwrite=True so existing blobs are replaced when uploading and the remote URL remains captured.
Adjusted the Azure file entity unit test to assert that the overwrite flag is supplied to upload_blob.
@sujata-m sujata-m requested review from MashB and susrisha September 24, 2025 05:59
…nal overwrite flag so every storage provider exposes the same interface.

- Adjusted the local file entity’s upload method to accept the new flag while keeping its upload behavior unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants