api (write plugin) upload - A valid login session was not found
-
now i have tried with a user token, and same response. other call api works.
nodebb version 1.7.3
-
I have no choice but to do so with forms-authentication
-
@david-levtov version 1.8.2 same issue
-
Hi all,
Confirmed working, here's the curl call I used:
$ cd /directory/with/file/to/upload $ curl -L https://localhost/forum/api/v2/util/upload?_uid=1 -H "Authorization: Bearer e3704a27-9368-4a3c-b743-0dbc5da08e39" -F "files[][email protected]"
Keep in mind my local dev uses a subfolder, that's why I am calling
localhost/forum
. You might call your own hostname, url, orlocalhost:4567/api...
Here is the return payload:
[ { "url": "/forum/assets/uploads/files/1524840237214-filename.jpg", "path": "/home/julian/Projects/nodebb/forum/public/uploads/files/1524840237214-filename.jpg", "name": "filename.jpg" } ]
-
@julian said in api (write plugin) upload - A valid login session was not found:
-F "files[]=@
hi, I don't understand, when I want to update words and pics, how to write the curl ?
thanks . -
thanks, I try to use the
curl -H "Authorization: Bearer {YOUR_TOKEN}" --data "title={TITLE}&content={CONTENT}&cid={CID}" http://localhost:4567/api/v1/topics
to send posts, It's all right.
Is there any samply about the "JSON Web Token " to send posts ?
very thanks . -
For anyone using NodeBB to upload a screenshot from node.js
const buffer = await createImage({ path: `screenshot/annotation:${ annotationID }` , encoding: 'binary' }) const result = await rp({ url: `${ endpoint }/util/upload?_uid=${ _uid }`, method: 'POST', json: true, headers: { Authorization , 'Content-Type': 'multipart/form-data' }, formData: { 'files[]': { value: buffer, options: { filename: `annotaion-${ annotationID }.jpg`, contentType: 'image/jpg' } } }, })