Still think FTP of large files should be improved
in rebol/core 2.6 since I cannot get any code
to work reliably in version 2.5.

Does not mean 2.5 has a bug,
just means that it is difficult for
a person to make it work reliably.

If it ain't simple and reliable,
it still needs to be improved (in my opinion.)

Or does someone have a function
that implements a simple and reliable way 
to FTP large files using rebol/core 2.5

-DV


-----Original Message-----
From: Vos, Doug [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 05, 2002 4:44 PM
To: '[EMAIL PROTECTED]'
Subject: [REBOL] Re: FTP large files (Answering my own question)


Actually - this is really crazy...
Can you get this code to work?


rfile: ftp://bigserver/bigfile.zip
lfile: %/d/data/bigfiles/bigfile.zip


inp: open/binary/direct     rfile
out: open/binary/new/direct lfile

total: 0
buf-size: 200'000'000                  ; change this to any size you want

buffer: make binary! buf-size + 2

while [not zero? size: read-io inp buffer buf-size][
    write-io out buffer size
    total: total + size
    print ["transferred:" total]
]

close inp
close out



-----Original Message-----
From: Vos, Doug [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 05, 2002 3:29 PM
To: '[EMAIL PROTECTED]'
Subject: [REBOL] FTP large files (Answering my own question)


About FTP of large files.
Here is a quote from the rebol documetation...
(sorry I did not read...)
Transferring Large Files
Transferring large files requires special considerations. You may want to
transfer the file in chunks to reduce the memory required by your computer
and to provide user feedback while the transfer is happening.
Here is an example that downloads a very large binary file in chunks.
        inp: open/binary/direct ftp://ftp.site.com/big-file.bmp
        out: open/binary/new/direct %big-file.bmp
        buf-size: 200000
        buffer: make binary! buf-size + 2
        while [not zero? size: read-io inp buffer buf-size][
            write-io out buffer size
            total: total + size
            print ["transferred:" total]
        ]
Be sure to use the /direct refinement, otherwise the entire file will be
buffered internally by REBOL. The read-io and write-io functions allow reuse
of the buffer memory that has already allocated. Other functions such as
copy would allocate additional memory.
If the transfer fails, you can restart FTP from where it left off. To do so,
examine the output file or the size variable to determine where to restart
the transfer. Open the file again with a custom refinement that specifies
restart and the location from which to start the read. Here is an example of
the open function to use when the total variable indicates the length
already read:
        inp: open/binary/direct/custom
            ftp://ftp.site.com/big-file.bmp
            reduce ['restart total]
You should note that restart only works for binary transfers. It cannot be
used with text transfers because the line terminator conversion that takes
place will cause incorrect offsets.

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to