1.5.7 • Published 7 months ago

@liblibaix/ext-oss v1.5.7

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

@liblibaix/ext-oss

oss工具类

使用

// upload
import { singleUploadForSD } from '@liblibaix/ext-oss';

// upload
const singleUploadForSD = Logger('@liblibaix/ext-oss');

singleUploadXX

文件上传,没有分片和断点续传,适合图片上传使用,测试可以看ui-upload.jsx

  • uuid
    • 类型: string
    • 说明: 用户uuid
  • file
    • 类型: file
    • 说明: 待上传文件
  • onCalcHashEnd
    • 类型: function
    • 说明: 文件hash计算完毕的回调,返回hash值
  • return
    • 类型: object
    • {
        file: 'web/image/8418faab24f34f3e904d67168708d7ec/test111test.png',
        url: 'https://model-ai-test.vibrou.com/web/image/8418faab24f34f3e904d67168708d7ec/test111test.png'
      }
// 上传-生图
await singleUploadForSD(uuid, file, onCalcHashEnd);

// 上传-生图-临时
await singleUploadForSDTmp(uuid, file, onCalcHashEnd);

// 上传-模版工具
await singleUploadForTemplate(uuid, file, onCalcHashEnd);

// 上传-专业工具
await singleUploadForPro(uuid, file, onCalcHashEnd);

// 上传-训练
await singleUploadForTraining(uuid, file, onCalcHashEnd);

// 上传-社区图片
await singleUploadForCommunityImage(uuid, file, onCalcHashEnd);

// 上传-社区其他
await singleUploadForCommunityOther(uuid, file, onCalcHashEnd);

modelUpload

模型上传,仅适用于模型上传,内部使用了分片上传,按1M分片

  • uuid
    • 类型: string
    • 说明: 用户uuid
  • file
    • 类型: file
    • 说明: 待上传文件
  • onCalcHashEnd
    • 类型: function
    • 说明: 文件hash计算完毕的回调,返回hash值
  • onUploadProgress
    • 类型: function
    • 说明: 上传文件的进度回调函数,返回percentage, checkpoint, res
  • return
    • 类型: object
    • {
        bucket:"liblibai-models",
        etag: "\"5ED2D125B7A4FC0CD9AEE8B1E1FA1DDD-50\"",
        file: "web/model/8418faab24f34f3e904d67168708d7ec/8565a714dca840f8652c5bae9249ab05f5fb5a4f9f13fbe23304b10f68252da2.safetensors",
        url: "https://model-ai-test.vibrou.com/web/model/8418faab24f34f3e904d67168708d7ec/8565a714dca840f8652c5bae9249ab05f5fb5a4f9f13fbe23304b10f68252da2.safetensors",
      }
await modelUpload(uuid, file, onCalcHashEnd, onUploadProgress);

// 示例代码
const file = files[0];
const res = await modelUpload(
  uuid,
  file,
  (hash) => {
    console.log('onCalcHashEnd', hash);
  },
  async (percentage, checkpoint, res) => {
    console.log('onUploadProgress', percentage, checkpoint, res);
  },
);
console.log(res);

copyObjectToTmp

将持久化bucket中的对象复制到临时bucket

  • url
    • 类型: string
    • 说明: 待复制的url
  • return
    • 类型: object
    • {
        file: 'web/image/8418faab24f34f3e904d67168708d7ec/test111test.png',
        url: 'https://model-ai-test.vibrou.com/web/image/8418faab24f34f3e904d67168708d7ec/test111test.png'
      }
await copyObjectToTmp(copyToTempUrl);

copyObjectToOnline

将临时bucket中的对象复制到持久化bucket

  • url
    • 类型: string
    • 说明: 待复制的url
  • return
    • 类型: object
    • {
        file: 'web/image/8418faab24f34f3e904d67168708d7ec/test111test.png',
        url: 'https://model-ai-test.vibrou.com/web/image/8418faab24f34f3e904d67168708d7ec/test111test.png'
      }
await copyObjectToOnline(copyToTempUrl);
1.5.7

7 months ago

1.5.6

7 months ago

1.5.5

7 months ago

1.5.4

7 months ago

1.5.3

7 months ago

1.5.2

7 months ago

1.5.1

7 months ago

1.5.0

7 months ago

1.4.9

7 months ago

1.4.8

7 months ago

1.4.7

7 months ago

1.4.6

7 months ago

1.4.5

7 months ago

1.4.3

7 months ago

1.4.1

7 months ago

1.4.0

7 months ago

1.3.9

7 months ago

1.3.8

7 months ago