The resolved AmplifyContext to operate on.
A UploadDataWithPathInput object.
An UploadDataServerWithPathOutput task. Await the result
promise to get the upload result.
// In a Next.js Route Handler
import { runWithAmplifyServerContext } from '@aws-amplify/adapter-nextjs';
import { uploadData } from 'aws-amplify/storage/server';
import { cookies } from 'next/headers';
export async function POST(request: Request) {
const formData = await request.formData();
const file = formData.get('file') as File;
const result = await runWithAmplifyServerContext({
nextServerContext: { cookies },
operation: (contextSpec) =>
uploadData(contextSpec, { path: `uploads/${file.name}`, data: file }).result,
});
return Response.json(result);
}
The resolved AmplifyContext to operate on.
A UploadDataInput object.
An UploadDataServerOutput task. Await the result promise to
get the upload result.
The key and accessLevel parameters are deprecated and may be removed in the next major version.
Please use path instead.
Upload data to the specified S3 object key. By default uses a single PUT operation to upload when the payload is less than 5MB. Otherwise, uses multipart upload to upload the payload.
Upload data to the specified S3 object path. By default uses a single PUT operation to upload when the payload is less than 5MB. Otherwise, uses multipart upload to upload the payload.
Server-side
uploadDatais intended for use in SSR contexts such as Next.js Route Handlers and Server Actions.