@The Fishcake🐶🐾 or anyone else, do you know why nostr-tools is adding the auth header to the form data in nip96.uploadFile? I was struggling trying to get this to work for a while and eventually I caught this. This causes nostr.build to return a 400 error cause it thinks there's multiple files in the payload. Brah I was ready to throw my computer out the window. 😂 https://github.com/nbd-wtf/nostr-tools/blob/6f334f31a75c63b452c966ecf50daf271275f3fa/nip96.ts#L344 I can make a PR tomorrow to remove this line.
also, for some reason you can't pass in window.nostr.signEvent to nip98.getToken, but you can pass in (e: EventTemplate) => window.nostr.signEvent(e). WAT?! man, i was trying for hours trying to upload a damn jpg using nip-96. https://github.com/nbd-wtf/nostr-tools/blob/6f334f31a75c63b452c966ecf50daf271275f3fa/nip98.ts#L21
i found the reason why. it used to be part of the spec until 3 months ago. https://github.com/nostr-protocol/nips/pull/1236
Ah, sorry for all the trouble. It is a bit of a PITA to use. You can take a look at how I implemented delete with nip96 here if it will help. https://github.com/nostrbuild/nostr.build/blob/main/build/src/delete.js 🐶🐾🫂🫂🫂
I plan to make a package specifically for nostr.build to get rid of the boilerplate and simplify it even more so people won’t even need to read the nips to figure out how to upload files
That would be splendid 🐶🐾🫂🎉
nostr.build responds with a 404 when i try to delete files. i've confirmed the file hash matches the file hash in the success response. here's an example URL that's returning a 404 when i send a delete request to it https://nostr.build/api/v2/nip96/upload/2f97733887b45a6a423b6eb9abd2587c5473c2bfaa8f894dba48939fadbd93d2
404 when you do it first time, or on a second attempt? Same media and npub? Not a duplicate upload? 🐶🐾🫡
I’ve tried it many times with my npub. Can’t get delete to work. 404 every time. I have a premium account. Not sure if that has anything to do with it.
Let me check, I may have bugs in that part of the code. Free should work well 🐶🐾🫡
I’ll try a different account when I get home
@The Fishcake🐶🐾 delete worked with npub on the free tier. So prob a big with premium accounts.
I see, I’ll check it out and try to fix asap 🐶🐾🫂
Ok, I know what the problem is, for paid accounts we cannot use hash, only custom name, since we allow duplicates of the media for many reasons (shared vs. archived) and to prevent account media access by knowing a hash. So you need to pass file name for it to work 🐶🐾🫡
Prob be good to update the error message to mention something about that
404 is correct, since file is not found. Cannot identify any other way, since it’s the matter of hash vs string and hash is the correct way for general things 🐶🐾🫡
Okay. I can just add documentation to the README about it. Prob add delete tomorrow. 🤙
You can mod the library to pass filename and that solves the problem. It will work for both 🐶🐾🫡
You also do not need to add Auth in form data, if you use JS and fetch, you should add Auth header to the http request 🐶🐾🫡
@fiatjaf i just made a PR to fix this https://github.com/nbd-wtf/nostr-tools/pull/426
I just merged your PR, but I didn't even know nostr-tools had nip96 support.
i didn't know either. @The Fishcake🐶🐾 told me yesterday.