Announcement

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

    explicitly define file upload metadata

    I'm still having trouble dealing with the binaryField_filename _fileSize, etc fields required for datasourceFields having type='binary'.

    The short version is this: If I just declare my (sql) datasource autoDerived='false', add the metadata columns to my table but leave them out of the datasource definition, magic happens and things 'just work' on my listGrids / upload forms.

    I need to insert records into that table by means other than through the UI. With the metadata fields undefined on the datasource, I'm not able to set values for them. If I define them explicitly, I can set values, but then my listGrid doesn't show filename or viewFile icons...

    So what's the trick to having it both ways?

    #2
    Why are you "unable to set values" on the metadata fields? Have you tried following the naming convention explained in the docs (just add _fileSize etc to the name that you give to the field)?

    Comment


      #3
      Well, maybe I've just not understood how it's supposed to work.

      (SC_SNAPSHOT-2011-07-27/PowerEdition Deployment 2011-07-27, by the way)

      I wasn't able to make it work by using autoDeriveSchema, so I define each field explicitly in the datasource. I currently have the metadata columns defined on my table, but not in the datasource. As I said, this all works when all I'm trying to do is upload a file through the UI. Filename, size, etc are all stored and retrieved properly.

      Code:
      CREATE TABLE attachment (
        attachment_id  NUMBER(9, 0),
        attachment      BLOB,
        attachment_filename  VARCHAR2(256)
        
        /* and so on */
      
      )
      Code:
      <DataSource 
        xmlns="http://www.smartclient.com/schema/datasource"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        ID="Attachment"
        tableName="ATTACHMENT"
        serverType="sql">
        
        <fields>
              <field name="ATTACHMENT_ID" type="sequence" sequenceName="profile_attachment_seq" primaryKey="true" />
              <field name="ATTACHMENT" type="binary"/>
        </fields>
      </DataSource>
      When I use DMI / DSRequest to set values, SGWT doesn't know anything about those fields, because they're not on the datasource. So something like this

      Code:
      values.put("ATTACHMENT", resume);
      values.put("ATTACHMENT_FILENAME", "SomeFile.docx");
      values.put("ATTACHMENT_FILESIZE", someByteArray.length);
      values.put("ATTACHMENT_DATE_CREATED", new Date());
      logs something like this

      Code:
      === 2011-08-16 13:30:49,874 [l0-1] INFO  SQLValuesClause - [builtinApplication.null] Ignored data for non-existent columns: [ATTACHMENT_DATE_CREATED, ATTACHMENT_FILENAME, ATTACHMENT_FILESIZE]

      Comment


        #4
        So have I found another bug here then?

        Comment


          #5
          Your code snippets look like they should work, this may be some kind of order of execution problem - we're checking on it.

          Comment


            #6
            Just looking for an update on this. Would it help if I prepared a test case?

            Comment


              #7
              Looking into it, this appears to work fine. What we should have spotted in your earlier posts is that this is a simple case problem - you are supplying an attribute called "ATTACHMENT_FILENAME", but we are looking for one called "ATTACHMENT_filename".

              Comment


                #8
                Well I was sure I'd tried that, but apparently not. Simple fix seems to work as advertised. Apologies for the noise.

                Comment

                Working...
                X