0
<?php
set_time_limit(0);
$myfile = gzopen($constpath . '.gz', 'w');
if (!$myfile){
    throw new \UnexpectedValueException('could not open datafeed.gz file');
}
$mystream = gzopen($constURL, 'r');
if (!$mystream){
    throw new \UnexpectedValueException('could not open gzip remote file');
}
echo '1<br>';
while (!gzeof($mystream)){
$data = gzread($mystream, 8096);
gzwrite($myfile, $data);
}
echo '4<br>';
gzclose($mystream);
gzclose($myfile);
echo '5<br>';
echo 'down done';

//begin ungzip

$fp = fopen($constpath . '.csv', 'w');
$gz = gzopen($constpath . '.gz', 'r');

if (!$gz){
    throw new \UnexpectedValueException(
         'could not open gzip file'
    );
}
if (!$fp){
    gzclose($gz);
    throw new \UnexpectedValueException(
        'could not open destination file'
    );
}

while (!gzeof($gz)) {
    fwrite($fp, gzread($gz, 8096));
}
gzclose($gz);
fclose($fp);
echo 'ungzip done';
?>

Hi, guys so above is my code, it intermittently allows me to download the gz file then unzip it, however it does not seem to be doing this in any sort of pattern or anything else, is there anything i need to know about how to use these functions like maybe is there a limit on the URL length (it's currently about 2.5K characters) but unfortunately not something i can change. what would people recommend on how to debug if there're bugs? or what i can do?

thanks!

EDIT: something i've noticed is that it is taking an absolute age to create a 25kB file, and previous to that it is 0kB, it then stops at 25kB

when i open the file in nano i get ^_�^H^@^@^@^@^@^@^C^@^@^@��^C^@^@^@^@^@^@^@^@^@ but when i unzip and open in windows there is nothing there?

Adam Waring
  • 25
  • 2
  • 11
  • the URL is `2.5K` characters ?!? or is that the file size ?!? – cmorrissey Jun 30 '15 at 18:26
  • the URL is, the file size is around 200MB – Adam Waring Jun 30 '15 at 18:44
  • Take a look at this ... http://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string ... my first question would be is why is the URL that long ... – cmorrissey Jun 30 '15 at 18:45
  • upstream provider required it to be that long, the shortest one with the least information in the file is still like 1.7K chars in length (URL length) and provides none of what i need – Adam Waring Jun 30 '15 at 18:47
  • i had a look at that earlier too, but i cannot understand why it would work earlier and now not be working. also the shorter url does not work atm, url is the only thing i have changed? – Adam Waring Jun 30 '15 at 18:49
  • does it being called as a require_once affect things? – Adam Waring Jun 30 '15 at 18:52

0 Answers0