Using image from Content Hub

  • Hi,
    I've been going through the process of importing an image from the content hub by following the tips here:-
    It all works as expected (Yay!) but I have no idea how I can get the imported app to stay put following an app restart 😞 - in the example above the WebApp Creator app doesn't need to retain the imported image.
    Does anyone have any idea (or can point to links on) how to import the image permanently? I've had a look at the rest of the documentation and other apps which use the content hub, but haven't had any luck so far.
    The image is stored (temporarily) in the HubIncoming folder but that, of course, doesn't survive a restart.

  • @Mick21367 You are correct about what you witness.
    But that is only normal behavior.
    The content hub allows you to gain access to some data (picture, music, video, ...), how the data is used is up to the destination app.
    So it's up to you to save that picture within your app. I actually never done it, but there are some folders you can write permanent data (database, documents, etc.)

    [Edit] I did find the documentation I was thinking of :

    I suggest to use the App Data path to permanently store the images you import using the content hub.

  • You have to copy the imported file or use move function from the ContentItem

    You have a commented example here

  • @CiberSheep Thanks for the link. Unfortunately, I still can't get it to work. I'm off to sleep now but if you get a chance, can you answer a couple of questions?
    How does the ContentItem move actually work? The documentation is less than clear, unfortunately. If possible, can you point me to a very simple example (sorry, I'm nowhere near clever enough to follow the example you gave!)?
    If it helps, the idea is that the user would replace a placeholder with an imported picture (a la Webapp Creator) and, if they wanted to, would click a button to permanently replace that placeholder - so the new picture would overwrite the old placeholder.
    Don't worry if this isn't possible - it's a learning experience for me rather than something remotely useful to anyone 🙂
    Thanks (and good night!)

  • @Mick21367 The ContentHub is quite confusing.

    The idea is:

    The important part is that we listen to stateChangeConnection state changes

    When the content (the picture in this case) is loaded we some actions. The interesting ones are: we go through the list of items imported and we could do a importPage.activeTransfer.items[i].move("[path]") were [path] is the path to a writable folder.

    This is one way of doing it. The other is using cpp. For example, in Gelek you can import a file

    StoreGameFile() is a function defined in cpp plugin

  • @CiberSheep Thank you - I've finally (!) managed to move it to a writeable location :-). Just for info, the variation I used was
    as I'm only importing one picture.
    A couple of extra questions - does anyone know if the above can be used to overwrite an existing file (the user may want to change the picture from time to time) or can the imported file (the one that we've moved) be deleted?
    @CiberSheep Thanks again - your help has been invaluable 🙂

  • @Mick21367 You have creator rights in the writable folder so it's doable to replace or delete the imported file.

Log in to reply