Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIfecicle Rules. How to set them #120

Closed
leopucci opened this issue Jan 30, 2022 · 1 comment · May be fixed by #122
Closed

LIfecicle Rules. How to set them #120

leopucci opened this issue Jan 30, 2022 · 1 comment · May be fixed by #122

Comments

@leopucci
Copy link

leopucci commented Jan 30, 2022

Hi there!
Seems that s3 compatible api is the go for tool.
But there are some lifecycle rules that only can be set on the b2 api.
Could someone help me on how to make a createBucket command containing the lifecycle info to set the rules upon creation?
I am trying this below, but the response comes with no lifecycle set.

try {
    await b2.authorize();

    const lifecycleRules = [
      {
        daysFromHidingToDeleting: 35,
        daysFromUploadingToHiding: null,
        fileNamePrefix: 'files/',
      },
    ];
    await b2
      .createBucket({
        bucketName: 'bucketSecretName',
        bucketType: 'allPrivate', // one of `allPublic`, `allPrivate`
        lifecycleRules,
      })
      .then((response) => {
        logger.info(response.data);
      });
  } catch (err) {
    logger.error('Error getting bucket:', err);
  }

And I get this response:

info: {
  accountId: '#########',
  bucketId: '##########',
  bucketInfo: {},
  bucketName: '###########',
  bucketType: 'allPrivate',
  corsRules: [],
  defaultServerSideEncryption: {
    isClientAuthorizedToRead: true,
    value: { algorithm: null, mode: null }
  },
  fileLockConfiguration: {
    isClientAuthorizedToRead: true,
    value: { defaultRetention: [Object], isFileLockEnabled: false }
  },
  lifecycleRules: [],  ==> COMES BLANK
  options: [ 's3' ],
  revision: 2
}

Thanks
Pucci

@leopucci
Copy link
Author

Looking on the source, seems that this lib does not accept additional parameters to be sent.
So I found another lib to be able to set the lifecycle rules.
if anyone is trying to pragmatically change the lifecycle settings upon bucket creation.
https://github.com/nodecraft/b2-cloud-storage
https://github.com/nodecraft/b2-cloud-storage/blob/main/docs.md#b2CloudStorage+createBucket

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 a pull request may close this issue.

1 participant