簡體   English   中英

是否可以將字節數組傳遞到m子ESB中的出站文件傳輸中

[英]Can a byte array be passed to an outbound file transport in mule ESB

我有一個Java組件,正在壓縮一個csv文件並從ByteArrayOutputStream返回一個字節數組。 我正在嘗試將其傳遞給要寫入操作系統的文件傳輸。 文件已寫入操作系統,但Windows報告我嘗試打開該文件時該文件無效。 首先,是否可以將字節數組發送到文件傳輸? 如果是這樣,那么我想我可能將不得不發布另一個問題,詢問我在壓縮CSV內容時做錯了什么...

這是Java的代碼段:

    List<String> csvFiles = (List<String>)message.getPayload();

    InputStream originalFile = null;
    ByteArrayOutputStream dest = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(dest); 

    File temp = new File("users.csv");
     originalFile = new 
       ByteArrayInputStream((csvFiles.get(0)).toString().getBytes());
     ZipEntry entry = new ZipEntry(temp.getPath());
     out.putNextEntry(entry);
     int count;
     while((count = originalFile.read()) != -1) {
        out.write(count);
     }
     originalFile.close();
     byte[] zipFileByteArray = dest.toByteArray();
     out.close();
     dest.close();
    return zipFileByteArray;

這是我流程的相關部分:

 <flow name="zip-csv">
    <component class="edu.ucdavis.iet.canvas.ZipFiles" doc:name="Java"/>
    <file:outbound-endpoint path="${message_archive.dir}" responseTimeout="10000" doc:name="save message to dir" outputPattern="temp.zip"/>
 </flow>

我建議使用針對此問題提交的ZipTransformer類@anupambhusari:

Mule Zip File並將壓縮文件發送到FTP服務器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM