Announcement

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

    #16
    Originally posted by Isomorphic View Post
    If you have to do it yourself, you would implement this via the techniques shown in the Custom Binary field sample and other samples in the same folder: for files being uploaded, use a DMI to replace the InputStream in the inbound DSRequest with a compressed input stream. For files being downloaded, modify DSResponse.data to replace the compressed InputStream returned by the DB with a non-compressed one.
    I am trying to implement the insert part, and I am not sure how to replace the InputStream in the inbound DSRequest.

    I have done this to test the replacement:
    Code:
    Map<String,Object> values = dsRequest.getValues();
    		values.put("f_datei", new String("a").getBytes());
    		dsRequest.setValues(values);
    So I try to replace the f_datei field (binary) with the bytes from "a". But when uploading a file, I still get the original file.
    So how exactly to replace the InputStream? There is no method "dsRequest.setUploadedFileInputStream" or something similar.

    Comment


      #17
      Do you also have a call to clearUploadedFiles() to get rid of the originally uploaded file?

      Comment


        #18
        No, thanks, adding it helped.

        Now I am trying to do the fetch-part, but I have the same problem: the file downloaded is the compressed file. Is there some similar API ?

        The code I am using is:
        Code:
        public DSResponse executeFetch(DSRequest dsRequest) throws Exception {
        		LOG.info("Executing Fetch: DokumenteDMIHandler");
        
        		DSResponse response = dsRequest.execute();
        		if (!(response.getData() instanceof Map)) {
        			return response;
        		}
        
        		InputStream compressedInputStream = (InputStream) ((Map) response
        				.getData()).get("f_datei");
        		if (compressedInputStream == null) {
        			return response;
        		}
        		LOG.info("Replacing content with uncompressed file");
        		InputStream decompressedInputStream = Utils
        				.bzip2Decompress(compressedInputStream);
        		((Map) response.getData()).put("f_datei", decompressedInputStream);
        		return response;
        
        	}
        The replacement is done here: ((Map) response.getData()).put("f_datei", decompressedInputStream);
        but I still get the compressed data downloaded. Is there something similar to "clearUploadedFiles()" here?

        Comment


          #19
          The data is a list, not a map.
          I think this solves the problem.

          Comment

          Working...
          X