where to place png file to reference in url

  1. 9 months ago

    ronaldo f

    6 Sep 2019 Xojo Pro Philippines

    Hi Guys,

    I had "logo.png" that I need to reference it from an external app.

    while testing, I tried to copy the logo.png to the debug root folder. But when I typed http://127.0.0.1:8080/logo.png the browser return 404: file not found.

    Anybody know where to put the logo.png so that it can be referred by an external app?

  2. Michel B

    6 Sep 2019 Testers, Xojo Pro

    What you are trying cannot work because a standalone app is not a web space.

    Your best bet would be to rent a cheap web space and put logo.png there.

  3. ronaldo f

    6 Sep 2019 Xojo Pro Philippines

    Meaning, any icon or images bundled from the compiled web app is now sharable, am I correct?

  4. ronaldo f

    6 Sep 2019 Xojo Pro Philippines

    How about using HandleSpecialURL /api ? Can it return picture so that external app can use it?

  5. Michel B

    6 Sep 2019 Testers, Xojo Pro
    Edited 9 months ago

    If you can find a way to serve the picture, yes indeed.

    You will have to find a way to Request.Print() the picture data in HandleURL, in response to such a URL as:

    http://127.0.0.1:8080/pictures/logo.png

    You could probably use a MemoryBlock to store the picture data, and read it as a string to print it.

  6. ronaldo f

    7 Sep 2019 Xojo Pro Philippines

    Thanks Michel.

    Maybe I can find that solutions soonest.

  7. Michel B

    7 Sep 2019 Testers, Xojo Pro

    This will help:

      Dim p As Picture = Canvas1.Backdrop
      Dim mb As MemoryBlock = p.GetData(Picture.FormatJPEG, Picture.QualityMax)
      Dim s As String = mb

    I found this here:
    https://forum.xojo.com/12785-store-picture-in-blob/0

    Basically, it should be as simple as verifying in HandleURL that the path indeed contains "pictures", and the name of the file.

    Then Request.Print(s)

  8. ronaldo f

    7 Sep 2019 Xojo Pro Philippines

    Thank Michel for your help.

    I resolved my problem using your assistance. Here is the code to make photo available to the public using "handleurl"

    Dim f As FolderItem
    f = GetFolderItem("logo.png")
    
    Dim p As picture
    p = picture.Open(f) 
    
    Dim mb As MemoryBlock = p.GetData(Picture.FormatJPEG, Picture.QualityMax)
    Dim s As String = mb
    
    Request.Header("Content-Type") = "Image/jpeg"
    Request.Print(s)
  9. Michel B

    7 Sep 2019 Testers, Xojo Pro

    You can dispense about the first 4 lines by simply dragging the picture in the project.

  10. Greg O

    7 Sep 2019 Xojo Inc scout.galaxy.barn

    @Michel B You can dispense about the first 4 lines by simply dragging the picture in the project.

    If the image isn’t actually used in the web project, that’s unnecessary overhead. Besides, he wanted to know how to serve the file from disk.

  11. Michel B

    7 Sep 2019 Testers, Xojo Pro

    Fortunately, I was here to help in the first place, as misguided as I was :/

  12. ronaldo f

    7 Sep 2019 Xojo Pro Philippines

    Thanks, guys.

    It this was now added to my code snips.

or Sign Up to reply!