I was trying to use nextjs13 which gives you both front end and back end (API and server routing ) out of the box.
I could simply move the back end to a standalone node service running something like express, (or similar libs) which I assume I would simply
npm install node-apprwrite
or something like that, and use the "server" getting started notes, and set ... the server API key
but I didn't want to do that, if I didn't have to. That would mean maintaining two sets of code for my front end and back end projects, and keeping them in sync. Ideally I have just 1 project, nedxtjs 13 and use it's built in separation of client and server and built in powerful support for rapidly building REST API's.
So you want to build this?
[ Client app ] <=> [ next js ] <=> [ Appwrite ]
Soo I'm not totally sure you can pull file out like form.get('image') as File
🧐
what I want is changing depending on the information I'm discovering. I want to know how everything works. I rekon I have a good idea of how the front end jwt / auth all works, but a lot of work I do involves building API's for corporate enterprise clients to integrate with...so I need to find examples of "server side" code that can publish "images/files" to appwrite storage.
The error you get...is there a stack trace to say what line that error comes from?
server side you definately can...because that's exactly how I'd process (on the server) the submitted POST/d image file ... and then save that file to AWS S3 or Cloudflare R2 ...or azure blob storage
So what can you do with that File? How do you do it against S3?
And how have you authenticated with Appwrite server side?
ok, we're going round in circles, I have a few very basic yes/no questions
- Are there any nextjs 13 or even 12 examples of using appwrite in both the client and server side?
I assume the answer 1 is NO. hence the long discussion we're having.
if NO to 1 ...above, then the next question is
- what is the best server side example code that I can look at, for creating a** server side REST web api using a node library like Express**?
I can figure the rest out on my own if I can get answer to 1 and 2 above. (I think)
how I will do whatever I do ...will totally depend on what the example documentation says. I will simply follow the docs, or copy the reference project. Hence why I'm asking if there's an example project anywhere?
The examples I did find were all client side using JWT.. and that's great I will need those later, AFTER i've finished building some test REST Api endpoints.
- https://github.com/Meldiron/appwrite-ssr-next-js
- It depends on what you need to do. You can just use the node SDK with an API key
txs Steven, I'm looking at that now
Hi Steven this is more advanced than the immediate problem I was trying to solve, but is massively helpful for what I will need to look at soon. (I've looked at the project briefly, and have forked it so that I have a permanent marker to come back to!) regarding my other problems, i will start a fresh blank project and just use the node SDK with API key. I suspect my "File" issue has nothing to do with appwrite perse. Txs for the time and for the link to appwrite-ssr-next-js!
apologies, just re-read the thread and you're right. Out of the box the File from browser and server are not the same, and you can't just "process" the stream of the file, that would be handled by middleware.
Which I have not configured, and is probably exactly the problem I'm experiencing.
Thank you!
ChatGPT is telling me to look at multer
and formidable
: I had mistakenly assumed that latest or recent nextjs libs included some opinionated default middleware for stuff like this and if I copied a reference getting started nextjs project it would all be clear and simple.
Lots to learn, phew!
txs again
Ya I saw formidable in my quick search too
If you want to use the web sdk, you can look at how we handle the input file. If what you pass in can be used that way, it might work: https://github.com/appwrite/sdk-for-web/blob/7b37a2bec1dbe47b55e2c962996046f56b763192/src/services/storage.ts#L76
txs, looking at that now...again, very helpful!
I don't think I will "hack" the web sdk, i think i'll use the server sdk, and when i've got the basics right, i will switch to using the web sdk as-is with auth ... which is the real purpose for it any way...
client side image uploading works well ... out of the box.
(deleted some comments about formidable package because it's off topic and after re-reading realise it's not helpful to other appwrite users or this thread! ciao all, love the support, A)
Recommended threads
- Having issues with login via CLI
``` ~/appwrite appwrite login --endpoint https://localhost/v1 --verbose ? Enter your email myvalidemai...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...