Symfony,如何阅读和上传谷歌存储中的epub文件并阅读它

问题描述 投票:0回答:1

我与"symfony/symfony": "~3.4","knplabs/gaufrette": "^0.3.0",合作将媒体上传到谷歌存储。但是如何使用epub文件,当我在正文epub请求中添加post文件时,我有没有名称或路径的文件

epubUrl = {Symfony\Component\HttpFoundation\File\UploadedFile} [7]
 test = false
 originalName = "RU EJTOP epub r1 (2).epub"
 mimeType = "application/octet-stream"
 size = 0
error = 1
*SplFileInfo*pathName = ""
*SplFileInfo*fileName = ""

和动作捕获错误

Warning: file_get_contents(): Filename cannot be empty

来自上传功能,因为file_get_contents需要一些路径

    public function upload(
    UploadedFile $file,
    $target,
    $allowedMimeTypesArray,
    $name
) {
    if (!$allowedMimeTypesArray) {
        $allowedMimeTypesArray = self::$allowedMimeTypes;
    }
    // Check if the file's mime type is in the list of allowed mime types.
    if (!in_array($file->getClientMimeType(), $allowedMimeTypesArray, true)) {
        throw new \InvalidArgumentException(
            sprintf(
                'Files of type %s are not allowed.',
                $file->getClientMimeType()
            )
        );
    }
    $y = file_get_contents($file->getPathname());
    $this->storeFile($target, file_get_contents($file->getPathname()), $name);

    return $name;
}

    private function storeFile($target, $data, $name)
{
    /** @var GoogleCloudStorage $fileSystem */
    $fileSystem = $this->getFileSystem($target);

    if (false === $fileSystem->write($name, $data)) {
        throw new \Exception('Storing file failed');
    }
}

如何在谷歌存储中上传epub文件,然后阅读它?以及如何在php中使用epub文件?

php symfony epub google-storage-api
1个回答
0
投票

我发现,php.ini upload_max_filesize增加了它 - 文件上传了路径和名称并获取内容并写入go google storage。因为需要在UploadedFile类中跟踪错误

© www.soinside.com 2019 - 2024. All rights reserved.