从 Cloudinary 中删除视频在 Laravel 中不起作用

Delete video from Cloudinary not working in Laravel

我可以删除 Cloudinary 中的图片,但不会删除视频。

控制器

public function update(Request $request, $id)
{
    $post = Post::find($id);

    if ($request->has('video')) {
        $file = $request->file('video');
        $result = $file->storeOnCloudinary('Blog');
        $uploadedFileUrl = $result->getSecurePath();
        $uploadedFileId = $result->getPublicId();

        if (isset($post->imageFileId)) {
            Cloudinary::destroy($post->imageFileId);
        }
        if (isset($post->videoFileId)) {
            Cloudinary::destroy($post->videoFileId);
        }

        $update = [
            'video' => $uploadedFileUrl,
            'videoFileId' => $uploadedFileId,
            'image' => null,
            'imageFileId' => null,
        ];

        $post->update($update);
    }
}

添加resource_type Cloudinary::destroy($post->videoFileId, ["resource_type" => "视频"]);

控制器

public function update(Request $request, $id)
{
    $post = Post::find($id);

    if ($request->has('video')) {
        $file = $request->file('video');
        $result = $file->storeOnCloudinary('Blog');
        $uploadedFileUrl = $result->getSecurePath();
        $uploadedFileId = $result->getPublicId();

        if (isset($post->imageFileId)) {
            Cloudinary::destroy($post->imageFileId);
        }
        if (isset($post->videoFileId)) {
            Cloudinary::destroy($post->videoFileId, ["resource_type" => "video"]);
        }

        $update = [
            'video' => $uploadedFileUrl,
            'videoFileId' => $uploadedFileId,
            'image' => null,
            'imageFileId' => null,
        ];

        $post->update($update);
    }
}