login about faq

Dear Sir,

I would like to know why PutFile does not overwrite my remote file and still returns a success message. I am running the same process twice where a file from my local pc is transferred to a server over ftp. After the second run, the file on the ftp would still be from the first run!

Thanks, Justin

asked May 29 '15 at 09:50

justinF's gravatar image

justinF
32

edited May 29 '15 at 10:40


You set the Ftp2.RestartNext property = true, and this indicates that the upload is to be resumed. If you are not resuming an upload, make sure that RestartNext = false so that the entire file is uploaded and the destination file is overwritten.

link

answered Jun 01 '15 at 07:25

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Thanks! That worked. According to the documentation of the Restart Next function: "The Chilkat FTP component sets the resume point by getting the existing size of the target (local) file." Thus if local file size = remote file size shouldn't RestartNext be automatically discarded? Because this function does prevent the file from becoming overwritten if misplaced. Thanks again.

(Jun 01 '15 at 08:29) justinF

If RestartNext is true, and the entire file already exists, then 0 bytes are transferred. In other words, the remote file is left as-is. (The RestartNext property should also be automatically reset to false, which should always be the case. If this is not true for the case where the entire file already exists, the please let me know..) -Matt

(Jun 01 '15 at 08:42) chilkat ♦♦

What I don't agree on with you Matt is your first line. If RestartNext is true, and the entire file already exists, I wanted RestartNext set to false BEFORE PutFile is executed so that if the file needs overwriting PutFile will overwrite it and RestartNext won't prevent it. Hence not 0 bytes are transferred but the new file is and replaces the old. Makes sense? thx

(Jun 01 '15 at 09:02) justinF

The RestartNext is set by the application prior to the next method call to upload/download a file. It indicates that the file, if incomplete, should resume transfer. The RestartNext is then reset back to false after the method call that does the transfer. Chilkat does not automatically decide whether or not to resume a transfer -- that is a decision in the hands of the app.

(Jun 01 '15 at 09:11) chilkat ♦♦

Precisely! I understand what you are saying but why does RestartNext prevent a file from being overwritten IF the file had been already transferred fully? This happens whenever the same process is run twice or more times. I can work around it but I believe the logic should be slightly different to allow files overwrite IF the file is transferred fully. thx again Matt

(Jun 01 '15 at 11:28) justinF

Please post the contents of the LastErrorText (with VerboseLogging turned on) so I can see what transpired..

link

answered May 29 '15 at 10:54

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

no errors were received. success was true as well. it's as if the transfer worked but the file remained the old one. what happens when a file with the same name is found? For example WinSCP pops up a confirmation dialog. Much appreciated chilkat!

(May 29 '15 at 10:59) justinF

The LastErrorText always contain information, even if successful. It allows cases like this to be debugged -- so we can see what happened. :)

(May 29 '15 at 11:14) chilkat ♦♦

When writing to a file that already exists (on the FTP server), it is the server that decides what happens. Typically, this would be to either overwrite, or fail the request. My guess is that you're not actually writing to that remote path.

(May 29 '15 at 11:16) chilkat ♦♦

chilkat I answered you below since the error text does not fit in the comment. Thank you

(Jun 01 '15 at 02:41) justinF

Chilkat, thanks for your concerns and explanation. I am certainly writing to the same remote path. The problem persists...here is the LastErrorText you asked for extracted exactly after the response from PutFile during the second run (when the file is supposed to overwrite but did not!).

ChilkatLog:
  PutFile(390ms):
    DllDate: Oct  1 2014
    ChilkatVersion: 9.5.0.44
    UnlockPrefix: EPHREMFTP
    Username: WS20:justin.farrugia
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 1
    LocalFilename: C:Usersjustin.farrugiaDesktopJustinTasks7 - StatementsTemp00047095841000002630004709584100000263_2015-5-17.pdf
    RemoteFilename: 0004709584100000263_2015-5-17.pdf
    ProgressMonitoring:
      enabled: yes
      heartbeatMs: 0
      sendBufferSize: 65536
    --ProgressMonitoring
    IdleTimeoutMs: 60000
    ReceiveTimeoutMs: 60000
    ConnectTimeoutSeconds: 60000
    uploadFromLocalFile(390ms):
      localFileSize: 115352
      uploadFromDataSource(390ms):
        initialGreeting: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 25 allowed.
220-Local time is now 07:14. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
        restartNext: 1
        modeZ: 0
        binaryMode: 1
        setupResumeUpload(63ms):
          sizeCmd(63ms):
            sizeCmdInner(63ms):
              sendCommand:
                sendingCommand: SIZE 0004709584100000263_2015-5-17.pdf
              --sendCommand
              readCommandResponse(63ms):
                replyLineQP: 213 115352
                commandResponse: 213 115352
                statusCode: 213
                readResponse: Elapsed time: 63 millisec
              --readCommandResponse
              size: 115352
            --sizeCmdInner
          --sizeCmd
          SizeCommandForAppendRestart: Elapsed time: 63 millisec
        --setupResumeUpload
        pbsz_protp(109ms):
          sendCommand:
            sendingCommand: PBSZ 0
          --sendCommand
          readCommandResponse(47ms):
            replyLineQP: 200 PBSZ=3D0
            commandResponse: 200 PBSZ=0
            statusCode: 200
            readResponse: Elapsed time: 47 millisec
          --readCommandResponse
          sendCommand:
            sendingCommand: PROT P
          --sendCommand
          readCommandResponse(62ms):
            replyLineQP: 200 Data protection level set to "private"
            commandResponse: 200 Data protection level set to "private"
            statusCode: 200
            readResponse: Elapsed time: 62 millisec
          --readCommandResponse
        --pbsz_protp
        setupDataConnection(94ms):
          passive transfer mode
          setupPassiveDataSocket(94ms):
            sendCommand:
              sendingCommand: PASV
            --sendCommand
            readCommandResponse(47ms):
              replyLineQP: 227 Entering Passive Mode (77,72,202,10,117,95)
              commandResponse: 227 Entering Passive Mode (77,72,202,10,117,95)
              statusCode: 227
              readResponse: Elapsed time: 47 millisec
            --readCommandResponse
            PassiveHostAddress: 77.72.202.10
            passiveHostAddr: 77.72.202.10
            dataConnect(47ms):
              hostname: 77.72.202.10
              port: 30047
              socket2Connect(47ms):
                connect2(47ms):
                  hostname: 77.72.202.10
                  port: 30047
                  ssl: 0
                  connectSocket(47ms):
                    domainOrIpAddress: 77.72.202.10
                    port: 30047
                    connectTimeoutMs: 60000000
                    connect_ipv6_or_ipv4(47ms):
                      This is an IPV4 numeric address.
                      Domain to IP address resolution not needed.
                      AddrInfoList:
                        AddrInfo:
                          ai_flags: 4
                          ai_family: 2
                          ai_socktype: 1
                          ai_protocol: 0
                          ai_addrlen: 16
                          ai_canonname: (NULL)
                        --AddrInfo
                      --AddrInfoList
                      connecting to IPV4 address...
                      ipAddress: 77.72.202.10
                      connect(47ms):
                        Waiting for the connect to complete...
                        myIP: 192.168.10.55
                        myPort: 54679
                        socket connect successful.
                      --connect
                    --connect_ipv6_or_ipv4
                  --connectSocket
                --connect2
              --socket2Connect
              socketOptions:
                SO_SNDBUF: 8192
                SO_RCVBUF: 8192
                TCP_NODELAY: 0
              --socketOptions
              dataConnectSuccess: 1
            --dataConnect
          --setupPassiveDataSocket
          setupPassiveDataSocket: Elapsed time: 94 millisec
        --setupDataConnection
        sendUploadCommand:
          sendCommand:
            sendingCommand: APPE 0004709584100000263_2015-5-17.pdf
          --sendCommand
        --sendUploadCommand
        convertDataConnToSsl(62ms):
          convertToTls(62ms):
            clientHandshake(62ms):
              clientHandshake2(62ms):
                processHandshakeRecord:
                  processHandshakeMessage:
                    processServerHello:
                      HelloExtension: renegotiation_info
                      HelloExtensionLen: 1
                    --processServerHello
                  --processHandshakeMessage
                --processHandshakeRecord
              --clientHandshake2
            --clientHandshake
            Secure Channel Established.
          --convertToTls
          ConvertToTls: Elapsed time: 62 millisec
        --convertDataConnToSsl
        Reading intermediate response for upload...
        readCommandResponse:
          replyLineQP: 150 Accepted data connection
          commandResponse: 150 Accepted data connection
          statusCode: 150
          readResponse: Elapsed time: 0 millisec
        --readCommandResponse
        intermediateResponseStatusCode: 150
        intermediateReply: 150 Accepted data connection
        sendUploadFileData:
          sendBufferSize: 65536
          Sending uncompressed...
          UploadData: Elapsed time: 0 millisec
        --sendUploadFileData
        closingDataConnection(62ms):
          shutdownChannel(62ms):
            sending close notify...
            sendCloseNotify:
              Turning on TCP_NODELAY.
            --sendCloseNotify
            reading SSL/TLS close notify...
            (bForceClose) socket shutdown..
            terminateConnection(15ms):
              TCP connection cleanly closed by peer.
              Cleanly terminated TCP connection.
            --terminateConnection
          --shutdownChannel
        --closingDataConnection
        skipFinalReply: 0
        Reading final response...
        readCommandResponse:
          replyLineQP: 226 File successfully transferred
          commandResponse: 226 File successfully transferred
          statusCode: 226
          readResponse: Elapsed time: 0 millisec
        --readCommandResponse
        FinalReply: Elapsed time: 0 millisec
        uploadRate: 0
        cumulativeNumBytesSent: 0
      --uploadFromDataSource
    --uploadFromLocalFile
    TotalTime: Elapsed time: 390 millisec
    Success.
  --PutFile
--ChilkatLog

link

answered Jun 01 '15 at 02:24

justinF's gravatar image

justinF
32

edited Jun 01 '15 at 03:54

Gert's gravatar image

Gert ♦
629141824

thanks Gert. how did you indent properly pls so I'd know for next time?

(Jun 01 '15 at 04:22) justinF

add < pre > and < /pre > tags around it. (without the extra spaces)

(Jun 01 '15 at 04:26) Gert ♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×50
×6

Asked: May 29 '15 at 09:50

Seen: 1,841 times

Last updated: Jun 01 '15 at 11:28

powered by OSQA