© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•14mo ago•
15 replies
Rohit

Uploading to aws s3 through edge function not working

I tried uploading to aws s3 through an edge function but its not executing, but when i tried the same code in a seperate nodejs environment it worked.
PS: Downloading file through edge function works.

This is the code in my edge function
import { Upload } from "npm:@aws-sdk/lib-storage";
import { S3Client } from "npm:@aws-sdk/client-s3";

async function handleUpload({
  file,
  path,
  contentType,
  upsert,
}: UploadParams): Promise<string> {
  try {
    const text = "Hello, this is a test upload!";
    const encoder = new TextEncoder();
    const fileStream = encoder.encode(text);

    const upload = new Upload({
      client: s3Client,
      params: {
        Bucket: BUCKET_NAME,
        Key: "testing/test.txt",
        Body: fileStream,
        ContentType: "text/plain",
      },
    });

    console.log("Starting test upload...");
    await upload.done();
    console.log("Test upload completed successfully!");

  } catch (error) {
    console.error("Test upload failed:", {
      name: error.name,
      message: error.message,
      stack: error.stack,
    });
    throw error;
  }
}
import { Upload } from "npm:@aws-sdk/lib-storage";
import { S3Client } from "npm:@aws-sdk/client-s3";

async function handleUpload({
  file,
  path,
  contentType,
  upsert,
}: UploadParams): Promise<string> {
  try {
    const text = "Hello, this is a test upload!";
    const encoder = new TextEncoder();
    const fileStream = encoder.encode(text);

    const upload = new Upload({
      client: s3Client,
      params: {
        Bucket: BUCKET_NAME,
        Key: "testing/test.txt",
        Body: fileStream,
        ContentType: "text/plain",
      },
    });

    console.log("Starting test upload...");
    await upload.done();
    console.log("Test upload completed successfully!");

  } catch (error) {
    console.error("Test upload failed:", {
      name: error.name,
      message: error.message,
      stack: error.stack,
    });
    throw error;
  }
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Edge Function supporting S3 operation - AWS S3 SDK
SupabaseSSupabase / help-and-questions
4mo ago
Edge Function not deploying
SupabaseSSupabase / help-and-questions
3y ago
Edge Function
SupabaseSSupabase / help-and-questions
5mo ago
Webhook not invoking Edge Function
SupabaseSSupabase / help-and-questions
3y ago