Zum Inhalt springen

Using Amazon S3 as Object Storage

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Browse the source code here.

LaunchFa.st provides you with the APIs to interact with Amazon S3, built on top of Web Standards.

Here’s how you would set up Amazon S3 to use it with LaunchFast:

  1. Follow the instructions in one of our blogs to set up Amazon S3.

  2. Update the environment variables via the following instructions:

Using the <Upload /> Component

To easily implemented file uploads in your application, import the Upload component in your application:

page.astro
---
import Upload from '@/components/Upload.astro'
---
<Upload />

GET files from Amazon S3

To fetch files from Amazon S3, pass the file’s slug as the file searchParam in /api/storage route as following:

page.astro
<script>
const getFile = new URL('/api/storage', window.location.origin)
getFile.searchParams.set('file', fileURL)
fetch(getFile.toString())
.then((res) => res.json())
.then((res) => {
const { filePublicURL } = res
console.log(filePublicURL)
})
</script>