Reading large binary files fails in Rebol

The following Rebol code crashes due to an error out of memory:

read/binary http://mirror.bytemark.co.uk/ubuntu-releases/lucid/
            ubuntu-10.04-desktop-i386.iso 

How can I use Rebol to read large binary files over HTTP?

+3
source share
3 answers

Rebol 2 ports are a bit of a mess. Thus, you cannot directly apply a sample of how to read a large file in parts , because it readdoes not work on port!in R2 (it works much less read/part).

But if you jump over several hoops and use the refinement /directto open the file, you will get something that will work:

; Rebol 2 chunking http download sample

filename: %ubuntu-10.04-desktop-i386.iso
base-url: http://mirror.bytemark.co.uk/ubuntu-releases/lucid/
chunk-size: 32000

in-port: open/binary/direct rejoin [base-url filename]
out-port: open/binary/direct filename
while [not none? data: copy/part in-port chunk-size] [
    append out-port data
]
close in-port
close out-port

( UPDATE: READ-IO Sunanda, R2 READ-IO. http . : P)

Rebol 3 port!. , , ...

; Rebol 3 chunking http download sample
; Warning: does not work in A99 release

filename: %ubuntu-10.04-desktop-i386.iso
base-url: http://mirror.bytemark.co.uk/ubuntu-releases/lucid/
chunk-size: 32000

in-port: open/read rejoin [base-url filename]
out-port: open/write filename
while [not empty? data: read/part in-port chunk-size] [
    write out-port data
]
close in-port
close out-port

, R3 alpha, /part read, HTTP.: (

+4

, .

This link describes how to read a file in chunks if you can find an FTP server for its source: http://www.rebol.com/docs/core23/rebolcore-13.html#section-11.12

A quick search assumes there are FTP servers for Ubuntu, but I have not checked whether they cover the version you need. Good luck

+1
source

Source: https://habr.com/ru/post/1749850/


All Articles