10 Replies Latest reply on Jul 6, 2004 4:17 AM by sys user

    Display an image with a Blob

    sys user Master

      Hi,

      I have an object Blob (it's an image) and I would display it in my theme. How I have to do?
      With or not?

      Thanks a lot for your help !!

        • 1. Re: Display an image with a Blob
          sys user Master

          With

          <img="">
          or not?



          • 2. Re: Display an image with a Blob
            jae Master

            the image is just stored as a blob in the database. if you wish to use it on an html page, you declare it the same way you would any other image using the img tag and the proper path to where the image is located.

            • 3. Re: Display an image with a Blob
              sys user Master

              Ok but, in the module html you can upload a file (like an image -> pn_content_type : image/gif) and you can display it using its id (pn_fid in the nukes database) with the tag . "myImage" being the id.
              How can you do that???

              Can you help me?

              • 4. Re: Display an image with a Blob
                sys user Master

                I'm so sorry, I forget the tag each time !!

                <img src="nukes/myImage">


                • 5. Re: Display an image with a Blob
                  Viet Master

                  why not use the HTML module itself to store these files by using a dedicated folder for that.

                  you can create insert files in the file tree by using the HTML commands that have been introduced recently. Look at the FilePlugin for the HTML module which does that.

                  then you can access your content with URLs like /a/b/c

                  • 6. Re: Display an image with a Blob
                    sys user Master

                    Yes, I have seen...
                    It works fine.. but I want to do the same thing with my own module.
                    So I succeed to store my image in my own database (thanks to you !!) and now, I would like to display my image.
                    I have looked at html module (+class Resource, ResourceManager, BLOBResource,...) and I don't understand how you can display a image only with its id !

                    Could you help me Julien?

                    • 7. Re: Display an image with a Blob
                      Viet Master

                      when you request /modules/toto/a/b/c.gif, the module toto will have a request to return the resource "/a/b/c.gif".

                      so when you handle the resource for /a/b/c.gif you need to return that.

                      • 8. Re: Display an image with a Blob
                        sys user Master

                        Ok, I tried to do it... but it doesn't work...
                        I look at your code...
                        You say :

                        /**
                         * Here we intercept the request and if the operation is userdisplay
                         * and the file is not text, we stream it.
                         */


                        I do, in my theme (because I want to display my image in my theme) :

                        File myFile = new File(idMyFile,nameMyFile,typeContent, content, idUser, date);
                        ResourceManager resManager = new ResourceManager();
                        resManager.start();
                        resManager.setMaxCacheSize(15);
                        resManager.add("idImage",(Resource)myFile);
                        Resource res = resManager.get("idImage"); //useless, I know, I can do a cast like (Resource)fic;
                        ResourceResult resultat = new ResourceResult(res);
                        NukesResponse resp = NukesLocator.getResponse();
                        resp.setResult(resultat);


                        I have to do errors because it doesn't work, but I don't know how to do.

                        Please help me !!! :o(

                        • 9. Re: Display an image with a Blob
                          sys user Master

                          I found several errors in my prior code...
                          I have corrected them. But it's doesn't work !!
                          Julien, could you help me ? I don't know how to do ! Thanks a lot !
                          There is the code in my theme, to display my image with the URL "http://myserver/nukes/idImage".

                          File myFile = new File(idMyFile,nameMyFile,typeContent, content, idUser, date);
                          // I add my file in the resourceManager
                          resourceManager.add("idImage",(Resource)fic);
                          
                          Resource res = getResource("idImage");
                          ResourceResult resultat = new ResourceResult(res);
                          NukesResponse resp = NukesLocator.getResponse();
                          resp.setResult(resultat);
                          


                          • 10. Re: Display an image with a Blob
                            sys user Master

                            It's ok, I do a module, and I can display my image via this module.
                            However, when I update my database, I reload my object (Blob) but my image isn't update in my page...
                            Someone can me why?