-
Notifications
You must be signed in to change notification settings - Fork 218
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
Showing
7 changed files
with
68 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
<script setup> | ||
const file = ref(null); | ||
const { data } = await useFetch('/api/presigned'); | ||
async function onSubmit() { | ||
const upload = file.value.files[0]; | ||
const image = await fetch(data.value, { | ||
body: upload, | ||
method: "PUT", | ||
headers: { | ||
"Content-Type": upload.type, | ||
"Content-Disposition": `attachment; filename="${upload.name}"`, | ||
}, | ||
}); | ||
window.location.href = image.url.split("?")[0]; | ||
} | ||
</script> | ||
<template> | ||
<div> | ||
<NuxtWelcome /> | ||
</div> | ||
<form novalidate @submit.prevent="onSubmit"> | ||
<input type="file" ref="file" accept="image/png, image/jpeg" /> | ||
<button type="submit">Upload</button> | ||
</form> | ||
</template> |
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,8 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
devtools: { enabled: true }, | ||
compatibilityDate: '2024-04-03', | ||
nitro: { | ||
preset: "aws-lambda", | ||
preset: 'aws-lambda' | ||
}, | ||
}); | ||
devtools: { enabled: true } | ||
}) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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,12 @@ | ||
import { Resource } from "sst"; | ||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; | ||
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; | ||
|
||
export default defineEventHandler(async () => { | ||
const command = new PutObjectCommand({ | ||
Key: crypto.randomUUID(), | ||
Bucket: Resource.MyBucket.name, | ||
}); | ||
|
||
return await getSignedUrl(new S3Client({}), command); | ||
}) |
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,17 @@ | ||
/* This file is auto-generated by SST. Do not edit. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import "sst" | ||
export {} | ||
declare module "sst" { | ||
export interface Resource { | ||
"MyBucket": { | ||
"name": string | ||
"type": "sst.aws.Bucket" | ||
} | ||
"MyWeb": { | ||
"type": "sst.aws.Nuxt" | ||
"url": string | ||
} | ||
} | ||
} |
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