ndk icon indicating copy to clipboard operation
ndk copied to clipboard

NIP-96 uploads fail even when successful

Open twenty-eighty opened this issue 1 year ago • 0 comments

Uploading files with Nip96.upload fail because of too strict status code handling. (tested with different servers)

The error:

Error uploading file: Error: Failed to upload file to https://files.sovbit.host/api/v2/media
    at Nip96.upload (index.mjs:7954:13)
    at async Object.onUpload (Editor.js:122:56)

The answer of the server:

Request URL: https://files.sovbit.host/api/v2/media
Request Method: POST
Status Code: 202 Accepted

The code that checks for the status code:

    if (res.status !== 200)
      throw new Error(`Failed to upload file to ${url}`);

twenty-eighty avatar Sep 29 '24 16:09 twenty-eighty