Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7504343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:32:35+00:00 2026-05-29T21:32:35+00:00

I can’t upload the same file twice in a row (second time, the content

  • 0

I can’t upload the same file twice in a row (second time, the content is updated), I get the following, how do i fix it??

Connected successfully uploading file: /tmp/Mall_bill_extract_20120213_170429_2.csv
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb:313:in `on_open'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `to_proc'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp/request.rb:87:in `call'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp/request.rb:87:in `respond_to'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:948:in `dispatch_request'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:911:in `when_channel_polled'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `to_proc'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/channel.rb:311:in `call'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/channel.rb:311:in `process'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:214:in `preprocess'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:214:in `each'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:214:in `preprocess'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:197:in `process'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:161:in `loop'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:161:in `loop_forever'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-ssh-2.2.1/lib/net/ssh/connection/session.rb:161:in `loop'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:802:in `loop'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@vitality_mall/gems/net-sftp-2.0.5/lib/net/sftp.rb:35:in `start'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/app/controllers/report_purchases_employer_controller.rb:139:in `export_to_bill_csv'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/base.rb:1253:in `send'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/base.rb:1253:in `perform_action_without_filters'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:183:in `handle_request'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:123:in `dispatch'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in `synchronize'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in `dispatch'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:39:in `dispatch'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/railties/lib/webrick_server.rb:103:in `handle_dispatch'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/railties/lib/webrick_server.rb:74:in `service'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:95:in `start'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `each'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `start'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:23:in `start'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/railties/lib/webrick_server.rb:60:in `dispatch'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/railties/lib/commands/servers/webrick.rb:66
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/vendor/rails/railties/lib/commands/server.rb:49
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Users/kamilski81/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/Users/kamilski81/Sites/pe/rails-apps/vitality_mall/script/server:3
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@global/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug-ide.rb:112:in `debug_load'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@global/gems/ruby-debug-ide-0.4.17.beta5/lib/ruby-debug-ide.rb:112:in `debug_program'
/Users/kamilski81/.rvm/gems/ruby-1.8.7-p352@global/gems/ruby-debug-ide-0.4.17.beta5/bin/rdebug-ide:87
-e:1:in `load'
-e:1

here is the code:

begin
  Net::SFTP.start('localhost', 'user', :password=>'pass') do |sftp|
    sftp.upload file_location, "/test/outbound_transactions/#{file_name}"
  end
rescue => ex
  puts ex.backtrace
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:32:37+00:00Added an answer on May 29, 2026 at 9:32 pm

    For data safety, you should:

    1. Upload the new file to a temporary filename.
    2. Rename the original to a .bak version.
    3. Rename the newly uploaded version to the original name.
    4. Delete the original.

    The reason for this is, you want to have one of the versions available if the code or connection fails for some reason.

    That could also step around the problem you’re seeing.

    I have seen FTP hosts lock the file immediately after it’s been uploaded. I don’t know why, because, when their server screwed up it made it impossible for me to delete the file. So, they could be locking/changing permissions or changing ownership of the file immediately after upload.

    The backtrace doesn’t help a whole lot because we don’t get the message contained in ex. You should do:

    puts ex.message
    

    or:

    puts ex.to_s
    

    before the puts ex.backtrace to get the actual message.

    The code that raised the exception doesn’t tell us much either:

    # Called when an +open+ request finishes. Raises StatusException if the
    # open failed, otherwise it calls #write_next_chunk to begin sending
    # data to the remote server.
    def on_open(response)
      @active -= 1
      file = response.request[:file]
      raise StatusException.new(response, "open #{file.remote}") unless response.ok?
      [...]
    

    so the puts ex.message would help you out.

    Also, upload is asynchronous, so you might want to add a wait. This is from the docs:

    Initiates an upload from local to remote, asynchronously. This method will return a new Net::SFTP::Operations::Upload instance, and requires the event loop to be run in order for the upload to progress. See Net::SFTP::Operations::Upload for a full discussion of how this method can be used.

      uploader = sftp.upload("/local/path", "/remote/path")
      uploader.wait
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I get a 'when to use' for these and others? <% %> <%#
Can anyone recommend a good library for generating an audio file, such as mp3,
Can anyone give me an example of how to return the following json simply
Can I be notified of the following events for an Activity: screenSizeWillChange screenSizeDidChange I
Can i get the source code for a WAMP stack installer somewhere? Any help
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can I convert a pdf to pcl file with ghostscript? I'm using Ghostscript 9.01
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can we do following in SQL Server 2005 query with convert function. MaxRegID =
Can somebody point me to a resource that explains how to go about having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.