|
@@ -1,4 +1,4 @@
|
|
|
-import OSS from "ali-oss";
|
|
|
+import OSS, { PutObjectOptions } from "ali-oss";
|
|
|
import Parse from "parse";
|
|
|
|
|
|
|
|
@@ -24,14 +24,23 @@ export class ProvierOssAli{
|
|
|
constructor(){
|
|
|
}
|
|
|
|
|
|
- async upload(file:File,onProcess:Function){
|
|
|
+ async upload(file:File,onProcess?:Function,options?:any){
|
|
|
await this.initClient();
|
|
|
let now = new Date();
|
|
|
let fname = `${Parse.User.current()?.id}/${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}/${now.getTime()}-${file?.name}`;
|
|
|
- const r1 = await this.client?.put(fname, file);
|
|
|
+ let putOptions:any = {headers:{}}
|
|
|
+ if(options?.acl){
|
|
|
+ if(!putOptions.headers) putOptions.headers = {}
|
|
|
+ putOptions.headers["x-oss-object-acl"] = options?.acl
|
|
|
+ }
|
|
|
+ const r1 = await this.client?.put(fname, file, putOptions);
|
|
|
console.log(file)
|
|
|
console.log('put success: %j', r1);
|
|
|
return r1
|
|
|
+ }
|
|
|
+ async get(url:string){
|
|
|
+ await this.initClient();
|
|
|
+ // const r1 = await this.client?.get(fname, file, putOptions);
|
|
|
|
|
|
}
|
|
|
|