overtrue / laravel-filesystem-qiniu

A Qiniu Storage filesystem for Laravel
472 stars 34 forks source link

上传策略 fsizeLimit 在哪里配置或传入? #19

Closed githubkl closed 2 years ago

githubkl commented 5 years ago

官方SDK示例如下,$policy中添加fsizeLimit等策略项:

//自定义返回值
$returnBody = '{"key":"$(key)","hash":"$(etag)","fsize":$(fsize),"name":"$(x:name)"}';
$policy = array(
    'returnBody' => $returnBody
);
$upToken = $auth->uploadToken($bucket, null, $expires, $policy, true);
print($upToken . "\n");

在本插件中如何使用呢?

overtrue commented 5 years ago
$auth = Storage::driver()->getAdapter();
$auth->uploadToken($bucket, null, $expires, $policy, true);
githubkl commented 5 years ago

多谢

yu1ec commented 5 years ago
$auth = Storage::driver()->getAdapter();
$auth->uploadToken($bucket, null, $expires, $policy, true);

超哥,我自己试了下,Storage::driver()压根不存在这个方法,只有一个drive,但是drive方法下,也没有getAdapter()方法? 我就想知道下,我如果调用的是Storage::disk(‘qiniu’),能不能配置fsizeLimit?

我穿了一个34m的文件,调试了一下,发现一直报一个错

Error {#237
  -url: "http://up.qiniup.com"
  -response: Response {#236
    +statusCode: 400
    +headers: array:16 [
      "Server" => "openresty/1.13.6.2"
      "Date" => "Fri, 15 Mar 2019 10"
      "Content-Type" => "application/json"
      "Content-Length" => "66"
      "Connection" => "keep-alive"
      "Access-Control-Allow-Headers" => "X-File-Name, X-File-Type, X-File-Size"
      "Access-Control-Allow-Methods" => "OPTIONS, HEAD, POST"
      "Access-Control-Allow-Origin" => "*"
      "Access-Control-Expose-Headers" => "X-Log, X-Reqid"
      "Access-Control-Max-Age" => "2592000"
      "Cache-Control" => "no-store, no-cache, must-revalidate"
      "Pragma" => "no-cache"
      "X-Content-Type-Options" => "nosniff"
      "X-Log" => "body"
      "X-Reqid" => "JTgAAL6CEiXtGowV"
      "X-Svr" => "UP"
    ]
    +body: "{"error":"invalid multipart format: multipart: message too large"}"
    +error: "invalid multipart format: multipart: message too large"
    -jsonData: array:1 [
      "error" => "invalid multipart format: multipart: message too large"
    ]
    +duration: 45.677
  }
}
neatstudio commented 5 years ago

$adapter = Storage::disk('xx')->getDriver()->getAdapter();