Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    read images from filesystem

    Good afternoon.
    I have a big doubt with the APIs of SmartGwt.
    It exists some way to get a lot of image files, to build, mmmm a photoAlbum?
    I have in mind build a photo visor y a way of iTunes coverflow, but i would like to obtain images from a specified folder..
    The question is, like i said, how can i obtain images from my filesystem, and put in a component in client side??

    #2
    You're out of luck here. Browsers are somewhat limited regarding submitting multiple files (that is, you can't just select a folder and upload everything in it). Two possible workarounds are
    1) flash-based file/folder selector
    2) active-x component

    Other than that, you're stuck to uploading files one by one.


    There are some facilities for batch file upload in smartgwt, take a look at that too.

    regards,
    Andrius J.

    Comment


      #3
      mmmmm i think i did not explain my doubt in a properly way..
      i donīt want a component to upload multiple files, i looking for a way
      to get a file(s) from a filesystem of the server, and show in a smart gwt or gwt form, because i read that JavaScript canīt do that...
      I mean how can i transform an InputStream(that contains my image file) and redirect that InputStream in a label, to mention an example...

      Comment


        #4
        1) Whatever file is in your .war, you can access directly via http.
        Probably not what you want for your photo album though.

        2) Create a FileDownloadServlet taking a filename/path as parameter which returns an image (works with anything really). There are a lot of good examples out there.
        Since the servlet runs on a server, it can access any file from any filesystem (it has access to).

        For example: http://host/app/servlets/DownloadServlet?get=somefile.jpg
        You can set that URL on any SmartGWT (you probably want class Img).

        Comment


          #5
          I use the following spring framework snippet to download files:

          Code:
              @RequestMapping("/fileDownload.do")
              void downloadFile(HttpServletResponse response, @RequestParam(value = "id", required = true) String id,
                                @RequestParam(value = "thumb", required = false) String thumbnail) throws IOException {
                  // get the file info 
                  MediaInfo info = mediaInfoRepository.get(id);
                  response.setBufferSize(info.getSize() > 1024 * 1024 ? 1024 * 1024 : (int) info.getSize());
                  String filename = thumbnail == null ? info.getFilename() : thumbnail;
                  response.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
          response.setContentType(servletContext.getMimeType(info.getFilename()));
                  File file = new File(UPLOAD_DIRECTORY + File.separator + info.getDirectory() + File.separator + filename);
                  response.setContentLength((int) file.length());
                  FileCopyUtils.copy(new BufferedInputStream(new FileInputStream(file)), response.getOutputStream());
              }
          This code returns either the image itself, or a thumbnail for it, depending on the "thumb" request parameter.

          regards,
          Andrius J.

          Comment


            #6
            Thanks to every one to answer me, i resolved my problem with this tutorial


            http://ikaisays.com/2010/09/08/gwt-blobstore-the-new-high-performance-image-serving-api-and-cute-dogs-on-office-chairs/

            Comment

            Working...
            X