net :: sftp :: statusexception(5,“不良消息”)发送大文件的块时:
简短版本:
在中发送文件 sftp 服务器在net :: sftp :: statusexception(stateusexception)中失败( 5,“坏消息”)
错误。
长版本:
我正在尝试将我的 ror 应用程序从客户的 sftp 服务器发送。
我正在使用Fog :: Storage
当我从s3
服务器中读取文件时。
这是我的示例代码:
file_paths = get_file_names()
Net::SFTP.start(sftp_domain, sftp_user, :password => sftp_password) do |sftp|
file_paths.each do |file_to_upload|
filename = nil
if Rails.env == "production"
filename = file_to_upload.file.path.split("/").last
# Create S3 Connection:
connection = Fog::Storage.new(provider: 'AWS'...)
# Find root directory:
bucket = connection.directories.get(ENV['MY_S3'])
# Send all files in directory, chunk-by-chunk:
sftp.file.open(sftp_folder + "/" + filename, "w") do |sftp_file|
bucket.files.get(file_to_upload.file.path) do |chunk|
sftp_file.write(chunk)
end
end
end
end
当单个文件超过默认块大小时,我会收到以下错误:
Excon::Error::Socket: Net::SFTP::StatusException (5, "bad message") (Net::SFTP::StatusException)
更多详细信息:
- 使用Rails 4.2.5.1.1。
- 使用Ruby 2.3.4P301(2017-03-30修订58214)[AARCH64-LINUX]
- GEM锁定在Net-SFTP(3.0.0)和Net-SSH(6.1.0)上。
- 足够小的文件可以正确发送 块 - 正确发送。
我尝试过的内容:
- 执行编码行不通(同样的错误)。
- 在一个块中读取大文件无效(内存错误)。
我很乐意根据需要添加更多详细信息,对不起,如果我错过了什么!
事先感谢大家!
Short Version:
Sending files from S3 in more than one chunk to SFTP server fails with a Net::SFTP::StatusException (5, "bad message")
error.
Long Version:
I'm trying to send a large file from my RoR application to a customer's SFTP server.
I'm using Fog::Storage
as I'm reading the file from my S3
server.
Here is my example code:
file_paths = get_file_names()
Net::SFTP.start(sftp_domain, sftp_user, :password => sftp_password) do |sftp|
file_paths.each do |file_to_upload|
filename = nil
if Rails.env == "production"
filename = file_to_upload.file.path.split("/").last
# Create S3 Connection:
connection = Fog::Storage.new(provider: 'AWS'...)
# Find root directory:
bucket = connection.directories.get(ENV['MY_S3'])
# Send all files in directory, chunk-by-chunk:
sftp.file.open(sftp_folder + "/" + filename, "w") do |sftp_file|
bucket.files.get(file_to_upload.file.path) do |chunk|
sftp_file.write(chunk)
end
end
end
end
ONLY when a single file exceeds the default chunk-size, I get the following error:
Excon::Error::Socket: Net::SFTP::StatusException (5, "bad message") (Net::SFTP::StatusException)
More details:
- Using rails 4.2.5.1.
- Using ruby 2.3.4p301 (2017-03-30 revision 58214) [aarch64-linux]
- Gem locked at net-sftp (3.0.0) and net-ssh (6.1.0).
- Files that are small enough to be sent in one chunk - are sent correctly.
What I tried:
- enforcing an encoding didn't work (same error).
- reading the large file in one chunk did not work (memory error).
I will be happy to add more details as needed, sorry if I missed something!
Thanks in advance to everyone!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论