B2_Command_Line_Tool icon indicating copy to clipboard operation
B2_Command_Line_Tool copied to clipboard

Using `create-bucket` and `--lifecycleRules` correctly

Open anjos opened this issue 7 years ago • 2 comments

I'm trying to use this flag on my system to create a bucket in which only the last version of the files are kept, but I have found no way to pass the correct set of parameters that can be accepted or documentation with examples. Here is what I'm trying:

$ b2 create-bucket --lifecycleRules '{"daysFromHidingToDeleting": 1, "daysFromUploadingToHiding": null, "fileNamePrefix": ""}' my-very-own-test-bucket allPrivate
ERROR: Bad request: array should start with bracket but found: {

I'm confused as it is stated here it should be a dictionary: https://www.backblaze.com/b2/docs/lifecycle_rules.html

Could somebody show a working example of this flag?

anjos avatar Mar 29 '18 06:03 anjos

There can be many rules per bucket - the command expects:

$ b2 create-bucket --lifecycleRules '[{"daysFromHidingToDeleting": 1, "daysFromUploadingToHiding": null, "fileNamePrefix": ""}]' my-very-own-test-bucket allPrivate

It would be interesting to add this to the documentation though.

anjos avatar Mar 29 '18 08:03 anjos

The error message should be improved by Backblaze/b2-sdk-python#188

mlech-reef avatar Feb 11 '21 18:02 mlech-reef

resolved with 4.0.2

mjurbanski-reef avatar Jun 17 '24 10:06 mjurbanski-reef