• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Image Upload as Topic

Scheduled Pinned Locked Moved Unsolved Technical Support
curluploadimage upload
13 Posts 3 Posters 1.0k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jpop71
    wrote on last edited by
    #1

    Hi All,

    Very impressed with what we've been able to figure out on our own via documentation. It seems we've hit something that either is not complete (so does not work) or it has been removed from NodeBB.

    What we are attempting to do is create an image board of sorts, but with all the cool features that NodeBB provides included. We figured out how to mass/batch created categories, but what we need to do now is mass/batch upload images as topic posts. Essentially, we want the image to be the initial post to be discussed about, voted on, etc.

    We found a few places online and in your documentation that tries to explain how to do something similar, but we have not found anything that describes precisely what we are wanting to do.

    curl -H "Authorization: Bearer 000000-0000-0000-0000-000000000000" -XPOST --data "files=/opt/nodebb/day.jpg" http://localhost:4567/api/topic/upload/thumb
    

    This was the last attempt that did not work.

    Note, we don't want to simply upload files. We want to insert these images into posts or as the posts. We would like to do this in batches.

    Is this possible on the current API release? If not, is this something in the works or would it be a feature request?

    Thank-you,
    Jeff

    1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    wrote on last edited by
    #2

    @julian mind taking a look?

    J 1 Reply Last reply
    0
  • J Offline
    J Offline
    jpop71
    replied to PitaJ on last edited by
    #3

    @pitaj Thank-you.

    We might have come across a method to do what we want, but it is going to take a bit more engineering to perfect things. We found a plugin called Imgbed that takes one of three options for embedding images into topics...markdown, bbcode, or html.

    With a properly formatted curl command we should be able to mass create topics using a simple content entry and some variable magic. Once the plugin is installed and activated, we can fill the content requirement with bbcode links to all of our images.

    curl -H "Authorization: Bearer 000000-0000-0000-0000-0000000000" -XPOST --data 'cid=35&title=fake post&content=![image-url.jpg|
    ](/assets/uploads/files/1633832725245-page-layout.jpg)' http://localhost:4567/api/v3/topics
    

    The above curl command uses the bbcode method for embedding an image. The image is located or will be located under /assets/uploads.

    As we keep trying, it will be interesting to hear what Julian says.

    Jeff

    PitaJP 1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to jpop71 on last edited by
    #4

    @jpop71 that's markdown. Bbcode would look like [img]https://www.bbcode.org/images/lubeck_small.jpg[/img]. You likely don't need the plugin at all.

    J 1 Reply Last reply
    0
  • J Offline
    J Offline
    jpop71
    replied to PitaJ on last edited by
    #5

    @pitaj Whoops you are right. It is markdown.

    1 Reply Last reply
    0
  • unfufadooU Offline
    unfufadooU Offline
    unfufadoo
    wrote on last edited by
    #6

    @pitaj

    Looking to solve this problem as well.

    Seems this method only creates a hyperlink as the content of the Topic post

    Where is this guys solution at least renders the image as the body within the content of the Topic post.

    both of these presume the image source is available via HTTP.

    What if the file are on the filesystem? file:// doesn't seem to work as the [img] doesn't invoke the upload process.

    From a review of the API it seems to post via API one has to upload the image first to assure the file is in the assets directory then a second API call to associate the asset URI to a Topic.

    Since ![image-url] and [img] are limited i'm not seeing a clear path forward as i'd like nodebb to 'own' the content.

    We've hobbled together a script to mass post via ![image-url] and visually it's what we'd like but again it's function is deponent upon the provided HTTP server being available. -no sad panda.

    pls advise

    PitaJP 1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to unfufadoo on last edited by
    #7

    @unfufadoo uploading the photos to NodeBB and then adding them to the post with ![image] does have NodeBB own the image.

    We've hobbled together a script to mass post via ![image-url] and visually it's what we'd like but again it's function is deponent upon the provided HTTP server being available. -no sad panda.

    Accessing NodeBB in the first place requires the http server be available. I don't know what the problem is.

    unfufadooU 1 Reply Last reply
    0
  • unfufadooU Offline
    unfufadooU Offline
    unfufadoo
    replied to PitaJ on last edited by
    #8

    @pitaj The difference is the contents is a hyperlink to the referenced image and not processed like an upload via the composer.

    PitaJP 1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to unfufadoo on last edited by PitaJ
    #9

    @unfufadoo no, if you use the correct markdown for an image embed, it will show the actual image.

    The leading ! is important. Example:

    ![burger](https://i.imgur.com/z9Sp1WS_d.webp?maxwidth=640&shape=thumb&fidelity=medium)
    

    burger

    Without it, just a link:

    [burger](https://i.imgur.com/z9Sp1WS_d.webp?maxwidth=640&shape=thumb&fidelity=medium)
    

    burger

    unfufadooU 1 Reply Last reply
    0
  • unfufadooU Offline
    unfufadooU Offline
    unfufadoo
    replied to PitaJ on last edited by unfufadoo
    #10

    @pitaj

    Right, that's easy however rather than http:// I need file:// to work.

    Also note this is visually the intended result which can be achieved however the image itself is served from the provided http source.

    In my use case it's intended the http source go away. I have at a OS file system level the contents of the old http source of the images. I would like to use file:// so that nodebb 'owns' the source files rather than just have content of http hyperlink

    PS. that's a darn good looking burger.

    PitaJP 1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to unfufadoo on last edited by
    #11

    @unfufadoo I'm still really confused on what you're trying to accomplish.

    Do you mean you just want file:// to show up in the post content but the image is still served in the browser over http?

    In my use case it's intended the http source go away. I have at a OS file system level the contents of the old http source of the images. I would like to use file:// so that nodebb 'owns' the source files rather than just have content of http hyperlink

    I cannot figure out what you're trying to say. A file:// resource points to a location on the file system of the user. So if your browser even allows that, it could point to a different file or a missing file depending on what computer is loading the page.

    What do you mean by "old http source of the images"?

    It doesn't sound like file:// is what you want. You said earlier:

    The difference is the contents is a hyperlink to the referenced image and not processed like an upload via the composer.

    But this is wrong. When you add a picture with the composer, the file is first uploaded to be hosted by NodeBB, and then a relative link to the file is added to the post.

    This is identical to the way you do it with the API. Upload the image file, then create a post with a link to the image.

    J 1 Reply Last reply
    0
  • J Offline
    J Offline
    jpop71
    replied to PitaJ on last edited by
    #12

    @pitaj We are trying to simply migrate 1000's of images from a mounted filesystem into NodeBB, but we want the images to be the post and owned by NodeBB when we are done. So the image should be embedded, not linked, and show up as the main thing to discuss in the forum.

    1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    wrote on last edited by
    #13

    You can avoid the upload step by copying the images directly to nodebb/public/uploads/migrated and then embedding them like

    ![image](/assets/uploads/migrated/image.jpg)
    
    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development