Skip to content

Custom Path for File Uploads with App Router #176

@umairayub79

Description

@umairayub79

I am encountering difficulties specifying a custom path for file uploads when using the 'next-s3-upload' library within a Next.js application, specifically with the App Router. The library provides an example for configuring the API route with a custom key function, but it seems that this configuration may not be fully compatible with the App Router.

Documentation Reference:
The relevant documentation snippet is as follows:

// pages/api/s3-upload.js
import { APIRoute } from "next-s3-upload";

export default APIRoute.configure({
  key(req, filename) {
    return `my/uploads/path/${filename}`;
  }
});

Issue Details:

Expected Behavior: I expect to be able to specify a custom path for file uploads using the library when using the App Router.
Actual Behavior: When using the provided configuration with App Router, I encounter errors such as 'TypeError: Body is unusable' or 'TypeError: s.status is not a function'.

Additional Information:

The configuration appears to be designed for the Pages Router, and it may not work seamlessly with the App Router in Next.js.
It seems that there might be a need for additional documentation or clarification on how to configure the library for the App Router in Next.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions