0

您好,我正在使用 gem net-sftp 上传文件列表,上传过程按预期工作,但是当我上传一个名称上带有前引号的文件时,远程服务器上的前引号会更改为“?”

代码

    local_file = 'C:/Users/UserA/Documents/RubyProjects/test/The Posesión.pdf'
    remote_file = '/home/UserA/test/The Posesión.pdf'
    sftp.upload!(local_file, remote_file)do |event, uploader, *args|
      case event
      when :open then
        puts "          Upload file: #{args[0].remote}"
      when :put then
        #puts "          Writing #{args[2].length} bytes to #{args[0].remote} starting at #{args[1]}"
      when :close then
        # args[0] : file metadata
        puts "          Upload finished with #{args[0].remote}"
      when :mkdir then
        # args[0] : remote path name
        puts "          Creating dir #{args[0]}"
      when :finish then
        upcount = upcount + 1
      end
    end

例子

本地文件名:The Posesión.pdf

远程结果: Posesi?n.pdf

有人知道避免这种行为的方法吗?

更新

我测试了相同的代码,但在不同的 sftp 服务器(Windows)中,我得到了一个错误,也许这是一个错误?

不兼容的字符编码:ASCII-8BIT 和 UTF-8

4

0 回答 0