chovy-3012 opened a new issue, #10088:
URL: https://github.com/apache/seatunnel/issues/10088

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   When using binary transfer in FTP sink/source, the parameter for 
`custom_filename`  does not work.
   
   I've reviewed the code and found that for CSV and text file formats,  
calling the method `AbstractWriteStrategy:getOrCreateFilePathBeingWritten` -> 
`AbstractWriteStrategy:generateFileName`, which uses the `custom_filename` 
parameter to implement custom filenames.
   
   However, for binary file formats, calling 
`BinaryWriteStrategy:getOrCreateFilePathBeingWritten`, here is the code:
   
   <img width="966" height="351" alt="Image" 
src="https://github.com/user-attachments/assets/0fac7b05-0616-459f-a6ae-97e05f00309a";
 />
   
   ```java
       public String getOrCreateFilePathBeingWritten(String relativePath) {
           String beingWrittenFilePath = beingWrittenFile.get(relativePath);
           if (beingWrittenFilePath != null) {
               return beingWrittenFilePath;
           } else {
               String[] pathSegments = new String[] {transactionDirectory, 
relativePath};
               String newBeingWrittenFilePath = String.join(File.separator, 
pathSegments);
               beingWrittenFile.put(relativePath, newBeingWrittenFilePath);
               return newBeingWrittenFilePath;
           }
       }
   ```
   
   
   Based on the code snippet provided, binary files use the `transaction 
directory + source filename` as the target filename, which is why custom 
filenames don't take effect.
   
   My question is: Why is this designed this way? Why can CSV and text formats 
support custom filenames while binary formats are forced to use the source 
filename?
   
   ### SeaTunnel Version
   
   2.3.12
   
   ### SeaTunnel Config
   
   ```conf
   sink {
       FtpFile {
           "port "=2121
           "path "="/home/ftp_test/out"
           "file_format_type"=binary
           "password "="xxx"
           "custom_filename"=true
           "file_name_expression"="binary3.csv"
           "user "="ftp_test"
           "plugin_input"="source_table"
           host="xxxxx"
           "connection_mode"="passive_local"
           "data_save_mode "="APPEND_DATA"
           "is_enable_transaction"=false
       }
   }
   source {
       FtpFile {
           path="/home/ftp_test/st.csv"
           password="xxxxx"
           "file_format_type"=binary
           port=2121
           "archive_compress_codec"=NONE
           "plugin_output"="source_table"
           host="xxxxxx"
           "connection_mode"="passive_local"
           user="ftp_test"
       }
   }
   env {
       "job.mode"=BATCH
       "execution.parallelism"="1"
   }
   ```
   
   ### Running Command
   
   ```shell
   ${SEATUNNEL_HOME}/bin/start-seatunnel-spark-3-connector-v2.sh --config 
binary.conf --deploy-mode client --master local
   ```
   
   ### Error Exception
   
   ```log
   Customing file name do not work in binary file transmission.
   ```
   
   ### Zeta or Flink or Spark Version
   
   Spark:3.1.3
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to