-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace AlphaSnow\LaravelFilesystem\Aliyun\Macros; | ||
|
||
use AlphaSnow\Flysystem\Aliyun\AliyunException; | ||
use AlphaSnow\LaravelFilesystem\Aliyun\OssClientAdapter; | ||
use Closure; | ||
use Illuminate\Filesystem\FilesystemAdapter; | ||
use OSS\Core\OssException; | ||
|
||
class ProcessObject implements AliyunMacro | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function name(): string | ||
{ | ||
return "processObject"; | ||
} | ||
|
||
/** | ||
* @return Closure | ||
*/ | ||
public function macro(): Closure | ||
{ | ||
$base64UrlEncode = function ($data): string { | ||
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); | ||
}; | ||
|
||
return function (string $path, string $process, string $save = "", array $options = []) use ($base64UrlEncode) { | ||
/** | ||
* @var FilesystemAdapter $this | ||
*/ | ||
$adapter = new OssClientAdapter($this); | ||
|
||
if($save == "") { | ||
$save = $path; | ||
} | ||
$process .= "|sys/saveas,o_".$base64UrlEncode($adapter->path($save)).',b_'.$base64UrlEncode($adapter->bucket()); | ||
|
||
try { | ||
return $adapter->client()->processObject( | ||
$adapter->bucket(), | ||
$adapter->path($path), | ||
$process, | ||
$adapter->options($options) | ||
); | ||
} catch (OssException $exception) { | ||
throw new AliyunException($exception->getErrorMessage(), 0, $exception); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters