-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
403fde1
commit 5fc70a0
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
<template> | ||
{{ params }} | ||
{{ data }} | ||
|
||
<Button label="Download" @click="download"></Button> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
const { params } = useRoute() | ||
const appName = params.appId as string | ||
const orgName = params.orgName as string | ||
const releaseId = params.detailArtifact as string | ||
const { data } = await useFetch('/api/artifacts/detail-artifact', { | ||
query: { | ||
appName: appName, | ||
orgName: orgName, | ||
releaseId: releaseId, | ||
}, | ||
}) | ||
const download = () => { | ||
const url = `/api/artifacts/download-artifact?fileObjectKey=${data.value?.fileObjectKey}` | ||
console.log(url) | ||
window.open(url, '_blank') | ||
} | ||
</script> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getStorageKeys } from "~/server/utils/utils" | ||
|
||
export default defineEventHandler(async (event) => { | ||
const prisma = event.context.prisma | ||
const { appName, orgName, releaseId } = getQuery(event) | ||
return await prisma.artifacts.findFirstOrThrow({ | ||
include: { | ||
apps: true, | ||
}, | ||
where: { | ||
releaseId: parseInt(releaseId?.toString() ?? ''), | ||
apps: { | ||
name: appName?.toString(), | ||
Organization: { | ||
name: orgName?.toString(), | ||
OrganizationsPeople: { | ||
every: { | ||
userId: event.context.auth.userId, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { GetObjectCommand } from "@aws-sdk/client-s3" | ||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner" | ||
import { getStorageKeys } from "~/server/utils/utils" | ||
|
||
export default defineEventHandler(async (event) => { | ||
const { fileObjectKey } = getQuery(event) | ||
const { assets } = getStorageKeys(event.context.auth, fileObjectKey?.toString()!) | ||
const signedUrl = await getSignedUrl(event.context.s3Client, new GetObjectCommand({ | ||
Bucket: 'app-deployin', | ||
Key: assets, | ||
})) | ||
|
||
await sendRedirect(event, signedUrl) | ||
}) |