Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am trying to take multiple files that were saved in a MS SQL Image field, and convert them back to their raw format.
I have tried following suggestions in the following thread: https://community.talend.com/t5/Design-and-Development/resolved-Create-file-from-a-blob-input-oracle...
My issue currently is that the job appears to be correctly looping through each IMAGE, but the tFileExportRaw is not correctly setting the filename. (See image1)
The following is the code in my tJavaRow
ByteArrayOutputStream baos = new ByteArrayOutputStream(); java.sql.Blob blob = (java.sql.Blob)input_row.Document; byte[] buf = new byte[1024]; java.io.InputStream in = blob.getBinaryStream(); int n = 0; while ((n=in.read(buf))>=0) { baos.write(buf, 0, n); } in.close(); byte[] bytes = baos.toByteArray(); output_row.IMAGE = bytes; output_row.filename = input_row.Fld1 + "-" + input_row.DocId + "." + input_row.FileExtension; System.out.println(((String)output_row.filename)); //this correctly displays each file name.
tFlowToIterate is set at defaults
See image2 for my tIterateToFlow setup.
Finally, the tFileOutputRow filename is set to: "C:/dev/DMSOut/" + row3.filename
With this setup, no value (null) is being passed through to the row3.filename, and the files overwrite each other leaving 1 file named "null".
I also tried exactly as the previously linked post instructed, and only the last item's filename is passed through. Thus, the files all overwrite eachother and I am left with 1 file.
You don't need use tIterateToFlow in case if You want to store each file separately
in combination with flow output component create file once, but not for each row
You must use tFlowToIterate and do iteration for each row independent
as variant:
tFlowToIterate -> on ComponentOk -> tJava (assign global variable to output column) -> tFileOutput (with iterational name)
this is will work for each iteration independently
I have tried your advice as best as I could, and have not been successful getting the job to generate unique files for each row (with a dynamic filename as set in the tJavaRow).
Could you elaborate on "You must use tFlowToIterate and do iteration for each row independent" ? How do I connect the tFlowToIterate to my tFileOutputRaw ?
Thanks!
Hi,
tJava - it is your code
tJavasFlex_2 - dummy connector
tJavaFlex_1
row3.IMAGE=(byte[])globalMap.get("row2.IMAGE");
filename in tFileOutput
I am facing the same issue.
I am using the same structure, tFlowToIterate and tIterateToFlow, but only the last file is generated, and the problem seems to be related to the name of the file:
((String)globalMap.get("row2.FileName"))
Any ideas or workarounds for this scenario?