ddan-js 3.1.3 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/ddan-upload.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ali-oss"),require("@alicloud/pop-core")):"function"==typeof define&&define.amd?define(["exports","ali-oss","@alicloud/pop-core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).dUpload=e.dUpload||{},e.OSS,e.aliCore)}(this,(function(e,t,r){"use strict";function
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ali-oss"),require("@alicloud/pop-core")):"function"==typeof define&&define.amd?define(["exports","ali-oss","@alicloud/pop-core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).dUpload=e.dUpload||{},e.OSS,e.aliCore)}(this,(function(e,t,r){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(t),n=s(r);e.Aliyun=class{bucket;accessKeyId;accessKeySecret;region;extra;__oss;__cdn;constructor({bucket:e,accessKeyId:t,accessKeySecret:r,region:s,...c}){this.bucket=e,this.accessKeyId=t,this.accessKeySecret=r,this.region=s,this.extra=c}get client(){return this.__oss||(this.__oss=this._getOSS()),this.__oss}_getOSS(){return new c.default({region:this.region,accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,bucket:this.bucket,...this.extra||{}})}async read(e){try{if(!await this.exist(e))return"";const t=await this.client.get(e);return t.content?.toString()||""}catch(t){return void console.log(`aliyun read ${e} error`,t)}}async delete(e){try{return await this.client.delete(e),!0}catch(t){return console.log(`aliyun delete ${e} error`,t),!1}}async exist(e,t={}){try{return await this.client.head(e,t),!0}catch(e){return!1}}async upload(e,t){try{return!(!e||!t)&&(await this.client.put(e,t),!0)}catch(e){return console.log(`aliyun upload ${t} error`,e),!1}}async put(e,t){try{return!(!e||!t)&&(await this.client.put(e,Buffer.from(t)),!0)}catch(t){return console.log(`aliyun put content ${e} error`,t),!1}}async putSymlink(e,t){try{if(!e||!t)return!1;return await this.client.putSymlink(e,t)}catch(e){return!1}}async browse(e,t){let r,s=!1;const c=e.endsWith("/")?e:`${e}/`;try{do{const e=await this.client.listV2({prefix:c,"continuation-token":r,"max-keys":"50"},{});for(let r of e.objects||[])t&&await t(r.name);r=e.nextContinuationToken,s=e.isTruncated}while(s);return!0}catch(t){return console.log(`aliyun browse ${e} error`,t),!1}}get cdn(){return this.__cdn||(this.__cdn=new n.default({accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,endpoint:"https://cdn.aliyuncs.com",apiVersion:"2018-05-10"})),this.__cdn}async refreshCDN(e,t="File"){try{let r={ObjectPath:e,ObjectType:t};const s={method:"POST",formatParams:!1};return await this.cdn.request("RefreshObjectCaches",r,s),!0}catch(t){return console.log(`aliyun refreshCDN ${e} err`,t),!1}}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/bin/ddan-upload.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"ali-oss";import t from"@alicloud/pop-core";class r{bucket;accessKeyId;accessKeySecret;region;__oss;__cdn;constructor({bucket:e,accessKeyId:t,accessKeySecret:r,region:c}){this.bucket=e,this.accessKeyId=t,this.accessKeySecret=r,this.region=c}get client(){return this.__oss||(this.__oss=this._getOSS()),this.__oss}_getOSS(){return new e({region:this.region,accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,bucket:this.bucket})}async read(e){try{if(!await this.exist(e))return"";const t=await this.client.get(e);return t.content?.toString()||""}catch(t){return void console.log(`aliyun read ${e} error`,t)}}async delete(e){try{return await this.client.delete(e),!0}catch(t){return console.log(`aliyun delete ${e} error`,t),!1}}async exist(e,t={}){try{return await this.client.head(e,t),!0}catch(e){return!1}}async upload(e,t){try{return!(!e||!t)&&(await this.client.put(e,t),!0)}catch(e){return console.log(`aliyun upload ${t} error`,e),!1}}async put(e,t){try{return!(!e||!t)&&(await this.client.put(e,Buffer.from(t)),!0)}catch(t){return console.log(`aliyun put content ${e} error`,t),!1}}async putSymlink(e,t){try{if(!e||!t)return!1;return await this.client.putSymlink(e,t)}catch(e){return!1}}async browse(e,t){let r,c=!1;const s=e.endsWith("/")?e:`${e}/`;try{do{const e=await this.client.listV2({prefix:s,"continuation-token":r,"max-keys":"50"},{});for(let r of e.objects||[])t&&await t(r.name);r=e.nextContinuationToken,c=e.isTruncated}while(c);return!0}catch(t){return console.log(`aliyun browse ${e} error`,t),!1}}get cdn(){return this.__cdn||(this.__cdn=new t({accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,endpoint:"https://cdn.aliyuncs.com",apiVersion:"2018-05-10"})),this.__cdn}async refreshCDN(e,t="File"){try{let r={ObjectPath:e,ObjectType:t};const c={method:"POST",formatParams:!1};return await this.cdn.request("RefreshObjectCaches",r,c),!0}catch(t){return console.log(`aliyun refreshCDN ${e} err`,t),!1}}}export{r as Aliyun};
|
|
1
|
+
import e from"ali-oss";import t from"@alicloud/pop-core";class r{bucket;accessKeyId;accessKeySecret;region;extra;__oss;__cdn;constructor({bucket:e,accessKeyId:t,accessKeySecret:r,region:c,...s}){this.bucket=e,this.accessKeyId=t,this.accessKeySecret=r,this.region=c,this.extra=s}get client(){return this.__oss||(this.__oss=this._getOSS()),this.__oss}_getOSS(){return new e({region:this.region,accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,bucket:this.bucket,...this.extra||{}})}async read(e){try{if(!await this.exist(e))return"";const t=await this.client.get(e);return t.content?.toString()||""}catch(t){return void console.log(`aliyun read ${e} error`,t)}}async delete(e){try{return await this.client.delete(e),!0}catch(t){return console.log(`aliyun delete ${e} error`,t),!1}}async exist(e,t={}){try{return await this.client.head(e,t),!0}catch(e){return!1}}async upload(e,t){try{return!(!e||!t)&&(await this.client.put(e,t),!0)}catch(e){return console.log(`aliyun upload ${t} error`,e),!1}}async put(e,t){try{return!(!e||!t)&&(await this.client.put(e,Buffer.from(t)),!0)}catch(t){return console.log(`aliyun put content ${e} error`,t),!1}}async putSymlink(e,t){try{if(!e||!t)return!1;return await this.client.putSymlink(e,t)}catch(e){return!1}}async browse(e,t){let r,c=!1;const s=e.endsWith("/")?e:`${e}/`;try{do{const e=await this.client.listV2({prefix:s,"continuation-token":r,"max-keys":"50"},{});for(let r of e.objects||[])t&&await t(r.name);r=e.nextContinuationToken,c=e.isTruncated}while(c);return!0}catch(t){return console.log(`aliyun browse ${e} error`,t),!1}}get cdn(){return this.__cdn||(this.__cdn=new t({accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,endpoint:"https://cdn.aliyuncs.com",apiVersion:"2018-05-10"})),this.__cdn}async refreshCDN(e,t="File"){try{let r={ObjectPath:e,ObjectType:t};const c={method:"POST",formatParams:!1};return await this.cdn.request("RefreshObjectCaches",r,c),!0}catch(t){return console.log(`aliyun refreshCDN ${e} err`,t),!1}}}export{r as Aliyun};
|
|
@@ -5,9 +5,11 @@ export default class Aliyun {
|
|
|
5
5
|
accessKeyId: string;
|
|
6
6
|
accessKeySecret: string;
|
|
7
7
|
region: string;
|
|
8
|
+
extra: any;
|
|
8
9
|
__oss?: OSS;
|
|
9
10
|
__cdn: any;
|
|
10
|
-
constructor({ bucket, accessKeyId, accessKeySecret, region }: {
|
|
11
|
+
constructor({ bucket, accessKeyId, accessKeySecret, region, ...extra }: {
|
|
12
|
+
[x: string]: any;
|
|
11
13
|
bucket: any;
|
|
12
14
|
accessKeyId: any;
|
|
13
15
|
accessKeySecret: any;
|