Announcement

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

    ViewFileItem in DynamicForm

    Hi,

    I have this in my .ds.xml:

    Code:
    <field name="USER_AVATAR" type="imageFile" showFileInline="true" maxFileSize="204800" />
    <field hidden="true" name="USER_AVATAR_filesize"  type="integer"/>
    <field hidden="true" length="256" name="USER_AVATAR_filename" type="text"/>
    <field hidden="true" name="USER_AVATAR_date_created" type="date"/>
    When I bind this DS to a ListGrid, the image stored in the DB.

    When I bind the same DS to a DynamicForm, I only see the field/button to upload a new image; the image already stored in the DB is not displayed.

    Is that expected?

    (If not, then don't start debugging this; It's possible that I am breaking it somehow, since the form in question is already doing a lot of things.)

    Thank you:

    Csillag

    ps. This is with the 02.17 nightly.

    #2
    Expected; this is what you'll see if the field is editable, if you set canEdit:false, you'll see the stored image.

    Comment


      #3
      I see. In this case, is there a way to configure a form to simultaneously show the currently stored image, and provide controls to change it (by uploading a new one)?

      Thank you for your help:

      Csillag

      Comment


        #4
        There currently is not.. one approach would be separate items, but remember, having the same field name is not allowed, so you might want a separate DynamicForm just to hold the ViewFileItem for the read-only display, embedded via a CanvasItem.

        Comment


          #5
          Is there an easy way to generate URLs to reference images that are stored in imageFile - type fields?

          (As far as I can tell, the image used now basically contain a full RPCRequest description, and thus are quite long and cryptic.)

          Is there a servlet to make this more adept for human consumption?

          If I make a servlet that synthetizes the same DSRequest (with the viewFile operation) from a smaller amount of data (like dsname, record id, field name) coming from the URL, and the forward it to IDACall, will that work?

          Also, how is caching handled on images stored this way?

          Thank you for your help:

          Csillag

          Comment


            #6
            There isn't an API currently to get the URL directly.

            Yes, you can build a servlet to serve the files with a simpler URL - just create a DSRequest, execute() it, get the stream from the response, and feed it to the servletResponse outputStream - no need to involve IDACall or RPCManager for this.

            Comment


              #7
              OK, and what about caching? (With and without the custom servlet layer.)

              Comment


                #8
                How do you mean?

                You can advertise cachability as usual, via standard HTTP headers.

                If you mean caching to disk, you have the stream.

                Comment


                  #9
                  Originally posted by Isomorphic
                  How do you mean?

                  You can advertise cachability as usual, via standard HTTP headers.

                  If you mean caching to disk, you have the stream.
                  I mean what do I have to do to achieve that the browser only downloads the image when it has changed.

                  Several things are needed for this; my question is, what is provided out of the box, and what do I have to do manually?

                  For example, when requesting the data via the IDACall, does the servlet ever send back a HTTP 304? What policy does it use to decide what cacheability headers to send back?

                  Thank you for explaining.

                  Csillag

                  Comment


                    #10
                    No, currently, it never sends back 304.

                    Binary fields have implicit, related metadata fields (see DataSource FieldType enum docs), one of which is the timestamp of upload. This could be used with standard HTTP headers to detect staleness and provide 304 responses (in your own servlet).

                    Comment

                    Working...
                    X