【问题标题】:my videos on google bucket can not fast forward or rewind我在谷歌存储桶上的视频无法快进或快退
【发布时间】:2021-12-30 05:37:53
【问题描述】:

所以我用 node.js 和 vue.js 构建了一个电子学习平台,并且我使用 GCP 存储桶来私下存储我的视频,除了我的视频无法快进或快退这一事实之外,一切都很完美,如果你尝试将视频移动到特定位置(可能在视频末尾)它会返回到您最初所在的位置,起初我认为这是一个 vue 问题,但我尝试直接从我的 GCP 存储桶仪表板播放此视频但它做同样的事情。只有当我使用火狐浏览器时它才能正常工作。 我正在使用 Uniform: No object-level ACLs enabled access control 和 Not public 权限设置。我是 GCP 的新手,我不知道可能是什么问题 这是我正在使用的 node.js 函数

const upload = async (req, res) => {
    try {
        if (!req.file) {
            res.status(400).send('No file uploaded.');
            return;
        }
        
        const gcsFileName = `${Date.now()}-${req.file.originalname}`;
        var reader = fs.createReadStream('uploads/'+req.file.originalname);
        reader.pipe(
            bucket.file(gcsFileName).createWriteStream({ resumable: false, gzip: true })
                .on('finish', () => {
                    // The public URL can be used to directly access the file via HTTP.
                    const publicUrl = format(
                        `https://storage.googleapis.com/bucketname/` + gcsFileName
                    );
                    // console.log('https://storage.googleapis.com/faslearn_files/' + gcsFileName)
                    fs.unlink('uploads/' + req.file.originalname, (err) => {
                        if (err) {
                            console.log("failed to delete local image:" + err);
                        } else {
                            console.log('successfully deleted local image');
                        }
                    });


                    res.status(200).send(publicUrl);
                })
                .on('error', err => {
                    console.log(err);
                    return
                })
                //.end(req.file.buffer)
        )
        // Read and display the file data on console
        reader.on('data', function (chunk) {
            console.log('seen chunk');
        });


    } catch (err) {
        console.log(" some where");
        res.status(500).send({
            message: `Could not upload the file: ${req.file.originalname}. ${err}`,
        });
    }
};

【问题讨论】:

  • 可能不是GCP,而是你正在使用的视频的编码,可以在这里分享视频的编码类型吗?

标签: node.js vue.js google-cloud-platform google-cloud-storage


【解决方案1】:

问题来自我对视频的编码方式,我应该使用 blob,但我使用了管道

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2015-07-02
  • 2016-08-29
  • 2020-10-26
  • 2019-12-10
  • 2018-08-26
  • 2023-03-24
  • 2020-02-15
  • 1970-01-01
  • 2020-07-02
相关资源
最近更新 更多