<?php

namespace Modules\Common\Support\Upload;

use Modules\Common\Support\Upload\HuaweiOBS\HuaweiOBSOperator;
use Modules\Common\Support\Upload\Uses\Upload;

class HuaweiOBSUpload extends Upload
{
    public function upload() :array
    {
        return $this->getUploadPath();
    }

    protected function huaweiOBSUpload(): string {
        $storePath = 'uploads' . DIRECTORY_SEPARATOR . $this->getUploadedFileMimeType() . DIRECTORY_SEPARATOR . date('Y-m-d', time());

        $filename = $this->generateImageName($this->getUploadedFileExt());

        $response = HuaweiOBSOperator::postFile($storePath . DIRECTORY_SEPARATOR . $filename, $this->file->getContent());

        return $response['ObjectURL'];
    }
}
