Skip to content

Commit

Permalink
Update: Don't create the buffer if blob already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
antidoid committed Jan 31, 2024
1 parent 48bc523 commit 80f022e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions qrCodeGenerator/function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def GenerateQRCode(req: func.HttpRequest) -> func.HttpResponse:
blobName = f"{modifiedUrl}-{style}-{color}.png"
blobClient = containerClient.get_blob_client(blobName)

# Converting qrcode data to bytes
buffer = io.BytesIO()
qrCodeData.save(buffer)
buffer.seek(0)
qrcodeInBytes = buffer.read()

# Upload the qrcode to blob container if it already doesn't exists
if not blobClient.exists():
# Converting qrcode data to bytes
buffer = io.BytesIO()
qrCodeData.save(buffer)
buffer.seek(0)
qrcodeInBytes = buffer.read()

blobClient.upload_blob(qrcodeInBytes)

return func.HttpResponse(
Expand Down

0 comments on commit 80f022e

Please sign in to comment.