Skip to content

Commit b208ee1

Browse files
committed
fix: set axios to return blobs for downloads
1 parent e7782c0 commit b208ee1

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import axios from "axios";
22

33
export default async function getModelArchive(modelId: number) {
4-
const response = await axios
5-
.get(`/api/models/${modelId}/data`)
4+
const data = await axios
5+
.get<Blob>(`/api/models/${modelId}/data`, { responseType: "blob" })
66
.then((res) => res.data);
7-
const data = await response.blob();
87
return data;
98
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import axios from "axios";
22

33
export default async function getProjectVersionArchive(projectVersion: number) {
4-
const response = await axios
5-
.get(`/api/projectVersions/${projectVersion}/data`)
4+
const data = await axios
5+
.get<Blob>(`/api/projectVersions/${projectVersion}/data`, {
6+
responseType: "blob",
7+
})
68
.then((res) => res.data);
7-
const data = await response.blob();
89
return data;
910
}

studio/features/api-sdk/uploadModel.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export default async function uploadModel(name: string, files: File[]) {
88
formData.append("files", file);
99
}
1010

11-
const response = await axios
12-
.post("/api/models", formData)
13-
.then((res) => res.data);
11+
const response = await axios.post("/api/models", formData);
1412

1513
return response;
1614
}

studio/features/api-sdk/uploadProjectVersion.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ export default async function uploadProjectVerion(
99
formData.append("projectId", projectId.toString());
1010
formData.append("file", file);
1111

12-
const response = await axios
13-
.post("/api/projectVersions", formData)
14-
.then((res) => res.data);
15-
16-
console.log(response);
12+
const response = await axios.post("/api/projectVersions", formData);
1713

1814
return response;
1915
}

studio/features/models/components/ModelUploadDialog.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function ModelUploadDialog({ close }: UploadModelDialogProps) {
4848
setIsPending(true);
4949

5050
const response = await uploadModel(name, files);
51-
if (response.ok) {
51+
if (response.status === 201) {
5252
close();
5353
} else {
5454
ToastQueue.negative("Failed to upload model");

0 commit comments

Comments
 (0)