Describe the bug
Model files from S3 fail to deploy correctly due to issue in init
To Reproduce
init against a workspace with GLB model files
deploy to a new workspace, attempt to open scene, model file fails to load with red box
Additional context
In the original code, we save the binary buffer to the file [1]
In the latest code, we convert the binary buffer into a UTF-8 string instead of preserving the binary [2]
e.g. confirmed with the following that the results are not the same:
// ts_test.ts
import * as fs from "fs";
import { S3, S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { writeFile } from "fs/promises";
const client = new S3Client({ region: "us-east-1" });
const client2 = new S3({ region: "us-east-1" });
const streamToBuffer = (stream: any) =>
new Promise((resolve, reject) => {
const chunks: any[] = [];
stream.on("data", (chunk: any) => chunks.push(chunk));
stream.on("error", reject);
stream.on("end", () => resolve(Buffer.concat(chunks)));
});
async function downloadFile() {
const command = new GetObjectCommand({
Bucket: "twinmaker-workspace-silo-261053700147-iad",
Key: "20231012_AWSContextModel_NoMaterials_Join_SingleNode.glb"
});
const data = await client.send(command);
const bodyContents = await streamToBuffer(data.Body) as Buffer;
fs.writeFileSync(`/tmp/s3file`, bodyContents);
}
async function downloadFileUtf() {
const data = await client2.getObject({
Bucket: "twinmaker-workspace-silo-261053700147-iad",
Key: "20231012_AWSContextModel_NoMaterials_Join_SingleNode.glb" });
const bodyContents = (await data.Body?.transformToString('utf-8')) as string;
fs.writeFileSync(`/tmp/s3file2`, bodyContents);
}
// downloadFile();
downloadFileUtf();
Describe the bug
Model files from S3 fail to
deploycorrectly due to issue ininitTo Reproduce
initagainst a workspace with GLB model filesdeployto a new workspace, attempt to open scene, model file fails to load with red boxAdditional context
In the original code, we save the binary buffer to the file [1]
In the latest code, we convert the binary buffer into a UTF-8 string instead of preserving the binary [2]
e.g. confirmed with the following that the results are not the same: