iidestiny / flysystem-oss Goto Github PK
View Code? Open in Web Editor NEW:floppy_disk: Flysystem adapter for the oss storage.
:floppy_disk: Flysystem adapter for the oss storage.
flysystem-oss/src/OssAdapter.php
Line 381 in 730a3c6
OSS 官方的 sdk 还有 音视频处理等的其它 api,
如果不获取到 $client
, 没办法调用这些函数 @iiDestiny
这是目前的代码,处理完host就直接拼接了 $path,导致假如有设置 root的情况下,该方法返回了错误的url
public function getUrl($path)
{
return $this->normalizeHost().ltrim($path, '/');
}
应该改为如下:
public function getUrl($path)
{
$path = $this->applyPathPrefix($path);
return $this->normalizeHost().ltrim($path, '/');
}
新增上传OSS文件最小长度限制参数:$minLength,支持外部传递最小,而非默认0
composer require "iidestiny/laravel-filesystem-oss:2.0" --ignore-platform-reqs
Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice /vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1214
flysystem-oss/src/Traits/SignatureTrait.php
Lines 27 to 36 in fd689dd
比实际时间晚了8个小时,他生成0时区的算法就是把当前时间表示时区的部分裁剪掉然后强制改成0时区,所以真正的ticket过期时间是8小时以后
https://help.aliyun.com/zh/oss/developer-reference/postobject#section-d5z-1ww-wdb
我想通过定义Content-Type来要求客户端上传的文件格式,但是发现signatureConfig方法没有对应的参数
Storage:files
方法无法正常使用,具体原因见
https://github.com/laravel/framework/blob/85c08016c424f6c8e45f08282523f8785eda9673/src/Illuminate/Filesystem/FilesystemAdapter.php#L591
这里用files这个过滤了返回的文件列表,看了官方自带的适配器返回的type是用SplFileInfo::getType这种方式返回的,而这个库是返回的文件类型,所以导致这个bug
请问有时间解决么
RT
将 oss 配置 添加到 filesystems.php 依旧是报错
'oss' => [
'driver' => 'oss',
'access_key' => env('OSS_ACCESS_KEY'),
'secret_key' => env('OSS_SECRET_KEY'),
'endpoint' => env('OSS_ENDPOINT'),
'bucket' => env('OSS_BUCKET'),
'isCName' => env('OSS_IS_CNAME', false), // 如果 isCname 为 false,endpoint 应配置 oss 提供的域名如:`oss-cn-beijing.aliyuncs.com`,否则为自定义域名,,cname 或 cdn 请自行到阿里 oss 后台配置并绑定 bucket
],
什么时候发布兼容Laravel10的版本啊
public function readStream(string $path)
{
$stream = fopen('php://temp', 'w+b');
$path = $this->prefixer->prefixPath($path);
try {
fwrite($stream, $this->client->getObject($this->bucket, $path, [OssClient::OSS_FILE_DOWNLOAD => $stream]));
} catch (OssException $exception) {
fclose($stream);
throw UnableToReadFile::fromLocation($path, $exception->getMessage());
}
rewind($stream);
return $stream;
}
建议将ENDPOINT与DOMAIN分开设置,因为经常会有内网传输需求 ,获取URL时又要使用外网URL,希望可以做一下兼容
php8.18和laravel9下面,会有下面警告
production.WARNING:DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /var/www/picoding/vendor/iidestiny/flysystem-oss/src/Traits/SignatureTrait.php on line 28
$prefix = 'flysystem-oss/ddd/aaa/';
$flysystem->write('file2.md', 'contents');
在windows下执行,上传到oss的文件路径为
"oss://flysystem-oss/ddd/aaa\file2.md"
flysystem-oss/src/OssAdapter.php
Line 126 in 730a3c6
$this->prefixer = new PathPrefixer($prefix, '/');
修改后windows上传oss路径正常
大佬,可以更新下OssAdapter.php
添加一个setVisibility
方法,便于设置某个文件的权限吗?
<?php
namespace Iidestiny\Flysystem\Oss
……
use League\Flysystem\AdapterInterface;
……
class OssAdapter extends AbstractAdapter
{
……
/**
* {@inheritdoc}
*/
public function setVisibility($path, $visibility)
{
$object = $this->applyPathPrefix($path);
$acl = ( $visibility === AdapterInterface::VISIBILITY_PUBLIC ) ? OssClient::OSS_ACL_TYPE_PUBLIC_READ : OssClient::OSS_ACL_TYPE_PRIVATE;
$this->client->putObjectAcl($this->bucket, $object, $acl);
return compact('visibility');
}
……
}
在获取签名的时候, 设置自定义字段 回调的时候为什么收不到值?
有人遇到这个情况吗.
OSS 官方文档的描述 :
发起回调时请求 body 的值,例如:key=$(object)&etag=$(etag)&my_var=$(x:my_var)。
支持 OSS 系统变量、自定义变量和常量,支持的系统变量如下表所示 。自定义变量的支持方式在 PutObject 和CompleteMultipart 中是通过 callback-var 来传递,在 PostObject中则是将各个变量通过表单域来传递。
这个 PostObject 中的各个变量表单域是啥????
前端web直传没有验签功能,希望能加上此功能。
flysystem-oss/src/OssAdapter.php
Lines 516 to 535 in fd689dd
但在阿里云 oss sdk 中,
https://github.com/aliyun/aliyun-oss-php-sdk/blob/339a4021da5e763eaa967bd7f67357b7061a3962/src/OSS/OssClient.php#L2532
/**
* Checks endpoint type and returns the endpoint without the protocol schema.
* Figures out the domain's type (ip, cname or private/public domain).
*
* @param string $endpoint
* @param boolean $isCName
* @return string The domain name without the protocol schema.
*/
private function checkEndpoint($endpoint, $isCName)
{
$ret_endpoint = null;
if (strpos($endpoint, 'http://') === 0) {
$ret_endpoint = substr($endpoint, strlen('http://'));
} elseif (strpos($endpoint, 'https://') === 0) {
$ret_endpoint = substr($endpoint, strlen('https://'));
$this->useSSL = true;
} else {
$ret_endpoint = $endpoint;
}
if ($isCName) {
$this->hostType = self::OSS_HOST_TYPE_CNAME;
} elseif (OssUtil::isIPFormat($ret_endpoint)) {
$this->hostType = self::OSS_HOST_TYPE_IP;
} else {
$this->hostType = self::OSS_HOST_TYPE_NORMAL;
}
return $ret_endpoint;
}
endpoint 还承载了是否开启 https 的作用。而当前插件在 OSS_IS_CNAME
为 false 时,自动的将 bucket 名字拼接到 endpoint 前,就产生了问题。
commit: 061f8e9
大佬,关于deleteDir
和createDir
可以采用以下方式实现,能否帮忙完善一下?我提交PR错误后一直检测不通过
/**
* Delete a directory.
*
* @param string $dirname
*
* @return bool
*/
public function deleteDir($dirname)
{
$fileList = $this->listContents($dirname,true);
foreach($fileList as $file){
$this->delete($file['path']);
}
return !$this->has($dirname);
}
/**
* create a directory.
*
* @param string $dirname
* @param Config $config
*
* @return bool
*/
public function createDir($dirname, Config $config)
{
$defaultFile = trim($dirname, '/') . '/oss.txt';
return $this->write($defaultFile, '当虚拟目录下有其他文件时,可删除此文件~', $config);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.