Skip to content

Commit

Permalink
Moved into branp/hunters-download-item
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonPacewic committed Jun 24, 2024
1 parent 9fb00ca commit 4bfa5a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
24 changes: 0 additions & 24 deletions fission/src/aps/APSDataManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,3 @@ export async function getFolderData(project: Project, folder: Folder): Promise<D
return undefined
}
}

export async function downloadItem(project: Project, item: Item): Promise<void | undefined> {
const auth = APS.auth
if (!auth) {
return undefined
}

try {
return await fetch(`https://developer.api.autodesk.com/data/v1/projects/${project.id}/items/${item.id}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${auth.access_token}`
}
}).then(x => x.json()).then(async x => {
console.debug(x)
const downloadLink = x.included[0].relationships.storage.meta.link.href
console.debug(`Download Link: ${downloadLink}`)
return await fetch(downloadLink, { method: 'GET', headers: { 'Authorization': `Bearer ${auth.access_token}` } })
}).then(x => x.blob()).then(x => { window.open(URL.createObjectURL(x)) })
} catch (e) {
console.error('Failed to download item')
return undefined
}
}
4 changes: 2 additions & 2 deletions fission/src/ui/modals/mirabuf/ImportMirabufModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Modal, { ModalPropsImpl } from "@/components/Modal"
import { FaPlus } from "react-icons/fa6"
import Button from "@/components/Button"
import Label, { LabelSize } from "@/components/Label"
import { Data, Folder, Hub, Item, Project, downloadItem, getFolderData, getHubs, getProjects } from "@/aps/APSDataManagement"
import { Data, Folder, Hub, Item, Project, getFolderData, getHubs, getProjects } from "@/aps/APSDataManagement"

interface ItemCardProps {
id: string
Expand Down Expand Up @@ -143,7 +143,7 @@ const ImportMirabufModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
id: x.id,
buttonText: "import",
onClick: () => {
downloadItem(selectedProject, x)
console.log(`Selecting ${x.displayName} (${x.id})`)
},
})
: ItemCard({
Expand Down

0 comments on commit 4bfa5a4

Please sign in to comment.