Closed buxuhunao closed 2 years ago
V9.0.3版本,PHP版本8.0.14
public function writeStream(string $path, $contents, Config $config): void { $auth = $this->getAuth(); $token = $this->uploadToken ?: $auth->uploadToken($this->bucket, $path); $this->withUploadToken(null); $params = $config->get('params', null); $mime = $config->get('mime', 'application/octet-stream'); $checkCrc = $config->get('checkCrc', false); $resourceData = ''; while (!feof($contents)) { $resourceData = $resourceData . fread($contents, 1024); } [$ret, $error] = $this->qiniuPutFile($token, $path, $resourceData, $params, $mime, $checkCrc); if ($error !== null) { $this->logQiniuError($error); } else { $this->lastReturn = $ret; } } private function qiniuPutFile( $upToken, $key, $fileResource, $params = null, $mime = 'application/octet-stream', $checkCrc = false ) { if ($fileResource === false) { throw new \Exception("file can not open", 1); } $file = $fileResource; $params = UploadManager::trimParams($params); $stat = fstat($file); $size = $stat['size']; if ($size <= QiniuConfig::BLOCK_SIZE) { $data = fread($file, $size); fclose($file); if ($data === false) { throw new \Exception("file can not read", 1); } $result = FormUploader::put( $upToken, $key, $data, new QiniuConfig(), $params, $mime, basename($key) ); return $result; } $up = new ResumeUploader( $upToken, $key, $file, $size, $params, $mime, new QiniuConfig() ); $ret = $up->upload(basename($key)); fclose($file); return $ret;
writeStream中的变量resourceData 为字符串,作为参数传入qiniuPutFile中,然后又把此变量作为资源传入fstat函数中导致报错。
试试 v9.0.4
可以了,感谢
V9.0.3版本,PHP版本8.0.14
writeStream中的变量resourceData 为字符串,作为参数传入qiniuPutFile中,然后又把此变量作为资源传入fstat函数中导致报错。