Skip to content

Commit

Permalink
converted uploader to forgeSDK
Browse files Browse the repository at this point in the history
  • Loading branch information
pan261 committed Feb 7, 2022
1 parent 1aebb0a commit 4b2d285
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require("fs").promises;
import * as config from "./config";

const ObjectsApi = new ForgeSDK.ObjectsApi();
const ItemsApi = new ForgeSDK.ItemsApi();

/**
* Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021
Expand Down Expand Up @@ -34,27 +35,13 @@ exports.download = async (projectID: string, itemID: string, fileName: string, d
};

const getStorageLocation = (projectID: string, itemID: string, credentials: ForgeSDK.AuthToken) => {
return axios.default({
method: "GET",
url: `https://developer.api.autodesk.com/data/v1/projects/${projectID}/items/${itemID}`,
headers: {
Authorization: `Bearer ${credentials.access_token}`,
},
})
.then((res: axios.AxiosResponse) => {
let data = res.data.included[0];
return ItemsApi.getItem(projectID, itemID, config.authClient, credentials)
.then((res: ForgeSDK.ApiResponse) => {
let data = res.body.included[0];
let storageID = data.relationships.storage.data.id;
storageID = storageID.substring(storageID.indexOf("/") + 1);
return storageID;
})
.catch((err: axios.AxiosError) => {
if (err.response) {
console.log(
"unable to get storage location for " +
itemID +
": " +
err.response.status
);
}
}).catch((err: ForgeSDK.ApiError) => {
console.log("unable to get storage location for " + itemID + ": " + err.statusCode);
});
};

0 comments on commit 4b2d285

Please sign in to comment.