import { Component, OnInit } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CompUploadComponent } from '../comp-upload.component';
import { ProvierOssAli } from '../provider-oss-aliyun';

@Component({
  selector: 'app-example-upload',
  templateUrl: './example-upload.component.html',
  styleUrls: ['./example-upload.component.scss'],
  standalone: true,
  imports:[CompUploadComponent,FormsModule,ReactiveFormsModule]
})
export class ExampleUploadComponent  implements OnInit {

  ossProvider: any|{ upload: any, signatureUrl: any, download:any } | undefined;
  constructor() { 
    this.ossProvider = new ProvierOssAli();
  }

  ngOnInit() {}

  upload(ev:any){
    console.log(ev)
  }

  downloadUrl:string = "http://hep-textbook.oss-cn-beijing.aliyuncs.com/undefined/2024-10-8/1728352740465-test.pdf"
  download(url:string,fileName?:string){
    let tempUrl = this.ossProvider?.download(url,fileName);
  }
  publicUrl:string|undefined = "http://hep-textbook.oss-cn-beijing.aliyuncs.com/undefined/2024-10-8/1728352740465-test.pdf"
  async public(){
    console.log(await this.ossProvider?.setACLPublic(this.publicUrl))

  }

  privateUrl:string|undefined = "http://hep-textbook.oss-cn-beijing.aliyuncs.com/undefined/2024-10-8/1728352740465-test.pdf"
  async private(){
    console.log(await this.ossProvider?.setACLPrivate(this.privateUrl))

  }

  signatureUrl:string = 'http://hep-textbook.oss-cn-beijing.aliyuncs.com/jjNvGRmN45/2024-10-9/1728443052684-211_merkblatt_verfahren_china_interview_chn.pdf'
  async signature(){
    console.log(await this.ossProvider?.signatureUrl(this.signatureUrl))
  }
}
