Google app engine 谷歌云存储通过节点上传,图像被破坏

Google app engine 谷歌云存储通过节点上传,图像被破坏,google-app-engine,google-cloud-storage,Google App Engine,Google Cloud Storage,显示使用节点库上载的图像似乎已损坏,尽管它们报告的大小正确 据报告,在使用方面也存在类似问题 使用上述代码,图像文件成功上载,代码转换base64上载的内容并写入指定的文件。但是,当浏览到公共URL时,图像似乎已损坏/损坏。手动上传的图像按预期工作。发布了关于存储损坏图像的节点的解决方案,并且Base64编码图像中的元信息似乎需要删除。更新工作代码如下 let fileName: string = `${namespace}/${data["name"]}`; let file:

显示使用节点库上载的图像似乎已损坏,尽管它们报告的大小正确

据报告,在使用方面也存在类似问题

使用上述代码,图像文件成功上载,代码转换base64上载的内容并写入指定的文件。但是,当浏览到公共URL时,图像似乎已损坏/损坏。手动上传的图像按预期工作。

发布了关于存储损坏图像的节点的解决方案,并且Base64编码图像中的元信息似乎需要删除。更新工作代码如下

    let fileName: string = `${namespace}/${data["name"]}`;
    let file: Storage.File = this.bucket.file(fileName);

    //add acl, who has access to this file
    console.debug("creating/modifying file", fileName);

    let base64Source = (data["source"] as string).replace(/^data:image\/(png|gif|jpeg);base64,/,'');
    let fileBuffer = new Buffer(base64Source,'base64');

    return from(file.save(fileBuffer, { contentType: data["contentType"], public: data["isPublic"] }))
        .pipe(map(() => {
            return { source: `${this.publicURLPrefix}/${fileName}` }
        }));
发布了关于存储损坏图像的节点的解决方案,并且Base64编码图像中的元信息似乎需要删除。更新工作代码如下

    let fileName: string = `${namespace}/${data["name"]}`;
    let file: Storage.File = this.bucket.file(fileName);

    //add acl, who has access to this file
    console.debug("creating/modifying file", fileName);

    let base64Source = (data["source"] as string).replace(/^data:image\/(png|gif|jpeg);base64,/,'');
    let fileBuffer = new Buffer(base64Source,'base64');

    return from(file.save(fileBuffer, { contentType: data["contentType"], public: data["isPublic"] }))
        .pipe(map(() => {
            return { source: `${this.publicURLPrefix}/${fileName}` }
        }));