阿里云oss:The bucket must be conform to the specifications

男娘i 2022-11-07 01:45 138阅读 0赞

在使用阿里云对象存储OSS服务-Node.js SDK时,遇到Error:The bucket must be conform to the specifications,怎么解决

官方文档

使用this.client.listBuckets(); 列举所有的存储空间即可,然后挑一个使用

  1. import * as OSS from 'ali-oss';
  2. import { Inject, Injectable } from '@nestjs/common';
  3. import ossConfig from '../../../config/oss';
  4. @Injectable()
  5. export class OssService {
  6. private client: any;
  7. public constructor() {
  8. console.log(ossConfig)
  9. this.client = new OSS({
  10. accessKeyId: ossConfig.accessKeyId,
  11. accessKeySecret: ossConfig.accessKeySecret,
  12. endpoint: ossConfig.endpoint
  13. })
  14. }
  15. // 列举所有的存储空间
  16. private async listBuckets () {
  17. try {
  18. let result = await this.client.listBuckets();
  19. console.log(result)
  20. } catch(err) {
  21. console.log(err)
  22. }
  23. }
  24. }

发表评论

表情:
评论列表 (有 0 条评论,138人围观)

还没有评论,来说两句吧...

相关阅读