
export class UploadMetaModel {
  public Id: number;
  public Format: string;
  public FileName: string;
  public Ts: Date;
  public By: string;
  public LastModified: Date;
  public Size: number;
  public Sha256: string;

  constructor(payload: Partial<UploadMetaModel>) {
    this.Id = payload.Id || 0;
    this.Format = payload.Format || '';
    this.FileName = payload.FileName || '';
    this.Ts = new Date (payload.Ts || new Date());
    this.By = payload.By || '';
    this.LastModified = new Date(payload.LastModified || new Date());
    this.Size = payload.Size || 0;
    this.Sha256 = payload.Sha256 || '';
  }

  get iconUrl(): string {
    const t = this.Format.replace( '/',  '-');
    return location.origin + '/assets/img/mime/' + t.toLowerCase() + '.png';
  }

  static iconUrlBySuffix(suffix: string): string {
    return location.origin + '/assets/img/suffix/' + suffix.toLowerCase() + '.png';
  }

  static thumbDefault(): string {
    return location.origin + '/assets/img/thumb_file_icon.webp';
  }
}

export class UploadMetalList {
  Total: number;
  Data: UploadMetaModel[];
}
