azure-sdk-for-js
azure-sdk-for-js copied to clipboard
[Storage] consider throwing when uploading to existing blobs
Possibly use etag
@bterlson, thoughts?
@XiaoningLiu @jiacfan
Sometimes, customers wants to override existing blob though. While sometimes, customers don't. Need to clarify the default behavior, and support other behavior by additional parameter. It's a cross language design topoic though.
I believe other languages (.NET and Java) has a boolean parameter overwrite with default value of false.
Sent from my Windows 10 device
From: xiaonlimsftmailto:[email protected] Sent: Tuesday, October 22, 2019 19:10 To: Azure/azure-sdk-for-jsmailto:[email protected] Cc: Jeremy Mengmailto:[email protected]; Authormailto:[email protected] Subject: Re: [Azure/azure-sdk-for-js] [Storage] consider throwing when uploading to existing blobs (#5594)
Sometimes, customers wants to override existing blob though. While sometimes, customers don't. Need to clarify the default behavior, and support other behavior by additional parameter. It's a cross language design topoic though.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-sdk-for-js%2Fissues%2F5594%3Femail_source%3Dnotifications%26email_token%3DABZ3QX3NEXDZJSGFJQBU4FLQP6XBJA5CNFSM4JBOZEOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB7ZGIA%23issuecomment-545231648&data=02%7C01%7CJeremy.Meng%40microsoft.com%7C05f3f02130364d33430008d7575e2caa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637073934292380413&sdata=bNM0HoIe3uMTJu8nw5w7r3rUzxhINtgFuuHz%2FoH7Odo%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABZ3QX7CDLMHVMU3K5EP7HTQP6XBJANCNFSM4JBOZEOA&data=02%7C01%7CJeremy.Meng%40microsoft.com%7C05f3f02130364d33430008d7575e2caa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637073934292380413&sdata=tvn1BdwP40SYfXylBDy5MbBayETEY3rnXExe7ZMk5BU%3D&reserved=0.
@tg-msft, What's the behaviour of .NET in this case?
You can take a look in ApiView for all the overloads, but our simpler methods have a bool overwrite
that defaults to false
. When overwrite == false
, we call the more complicated overload and pass IfNoneMatch = new ETag("*")
for the conditions.
I think throwing by default is the right behavior here, and an option overwrite: true
to turn this off seems good too.
It will introduce breaking changes now as we are already GA and we conform to the original REST API's behavior, i.e. overwrite by default.
We could add a overwrite option default to true, or an uploadIfNotExists
interface.
@bterlson @xirzec @XiaoningLiu What do you think now?
If we've already GA'd overwrite behavior, then I think we could add the inverted flag (throwOnOverwrite = false
) and maybe consider logging a verbose/debug message when we're overwriting with instructions on how to flip the flag if this behavior is unexpected?
User can get the functionality by calling the interfaces with the ifNoneMatch
condition.
await blockBlobClient.upload(body, body.length, { conditions: { ifNoneMatch: "*"} });
Another thing to think about is how we should deal with it in the parallel upload functions, where we call several stageBlock
and then commitBlockList
. commitBlockList
supports the conditon butstageBlock
doesn't. So we will stage all the blocks and then throw when we commit the block list. Not sure if this is acceptable for the user.