Disable file upload entirely

Solved Technical Support

Suggested Topics

  • 0 Votes
    1 Posts

    Hi all,

    I'm trying to use the recently introduced WriteAPI to create topics and concurrently upload a file.
    I'm doing it via Python and I've already succeeded in create a simple topic without a file using something lilke

    payload = { "cid": cid, "title": title, "content": message } headers = { 'Authorization': 'Bearer '+nodebbToken, 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

    but when it's about files using

    payload = { "cid": backstage_cid, "title": backstage_title, "content": backstage_message } headers = { 'Authorization': 'Bearer '+nodebbToken, 'Content-Type': 'multipart/form-data' } verifySSL = False print (payload) if (useFile): with open(backstage_file, 'rb') as f: response = requests.request("POST", url, headers=headers, data=payload, verify=verifySSL, files={backstage_file: f})

    it returns
    Error: Required parameters were missing from this API call: cid, title, content cause passing the parameters in a plain dictionary rather than a JSON object seems not doable.

    The switch from JSON to dictionary is needed otherwise I wouldn't have been able to pass a file together with such header

    headers = { 'Authorization': 'Bearer '+nodebbToken, 'Content-Type': 'multipart/form-data' }

    Has anybody valuable suggestions here?

    Thanks in advance, Riccardo

  • 0 Votes
    26 Posts

    So finally the error is gone.

    I added this environment variable to my Openshift proyect:
    LD_PRELOAD = '/opt/app/node_modules/sharp/vendor/lib/libz.so'

    This is the url to sharp inside my node_modules.

    When I opened the terminal I get and error saying that it can't be preloaded but after installing all dependencies the error is gone, and I could upload images!!!

    Thank you very much @PitaJ !!!!

  • 0 Votes
    3 Posts

    I was crating bug to GitHub, but thought that this could be know issue, after upgrade, so thats why added this question first... I did se you managed to do it fist, so I added information to there. I use tags, both 1.4.5 and 1.4.6 has this issue.

    Upload cover picture does not work when using subfolder ยท Issue #5631 ยท NodeBB/NodeBB

    Uploaded cover picture path does not contain the relative_path.


    GitHub (github.com)

  • 0 Votes
    4 Posts
  • 0 Votes
    1 Posts

    I will need upload functional in future plugin.
    Is there any Upload API already in NodeBB ready for plugins use?
    I would like to use ready to use solution, if any, before I will do it myself ๐Ÿ˜‰