#✅ - Amplify Storage and NextJS Sever Actions

1 messages · Page 1 of 1 (latest)

daring thicket
#

Hi All.

I have seen some other posts here regarding uploading to Amplify Storage via Server Actions but non of them have been answered so I will ask again regarding this issue.

I hope that someone here can help me with some clarification or help regarding the Amplify Storage and NextJS Server Actions.

We are using "getCurrentUser" to get the user data and we use "generateServerClientUsingCookies" to fetch and update amplify data.

but I we also want to upload/update data to the storage via the server but I cant find any documentation on how to achieve this. I am looking at this portion of the page #supported-apis-for-nextjs-server-side-usage where it shows the supported api's and under storage there are only functions for fetching data and nothing to do with adding anything.

Am i just missing something obvious or is this just not available to do via the server and I have to do it via the client which we would have to modify or flow to make this work.

Here is an example of how we are trying to upload a file via the server

**_...

const { userId } = await AuthGetCurrentUserServer();

....

const audioStream = await response.blob();
const filename = media/${userId}/${projectId}/${uuidv4()}.mp3;

const uploadResponse = await uploadData({
path: filename,
data: audioStream,
options: { contentType: 'audio/mpeg' },
}).result;_**

and here is the error we are getting

daring thicket
#

Hi, Could someone please give me a response on this. Even if its we dont know, it cant be done, as all the questions on this subject have been ignored here and its really frustrating when reaching out for help and feeling stupid and no one answers its a really crappy feeling.

daring thicket
#

Anyone???

smoky kindle
#

Another way you could try, is running the Amplify.configure inside the server side route, then run the upload data. You would need to setup Auth and the storage parts of it. You can look at the amplify_outputs.json to see those values. You can also see how it's done on the function side here. https://docs.amplify.aws/react/build-a-backend/functions/examples/create-user-profile-record/

Just realize that you won't be able to import in env in from $amplify... since that only works in lambda functions

#

@desert night can you open another thread on your issue. Looks to be different then the first one

ruby berryBOT
#

✅ - Amplify Storage and NextJS Sever Actions