Status Update
Comments
ma...@google.com <ma...@google.com>
di...@formitize.com <di...@formitize.com> #2
$zip = new ZipArchive();
move_uploaded_file($_FILES['zip']['tmp_name'], DIR_GAE_VAR . $_FILES['zip']['name']);
if($zip->open(DIR_GAE_VAR . $_FILES['zip']['name']))
{
$zip->extractTo(DIR_GAE_VAR . "upload/" . $group . '/');
}
Warning: ZipArchive::extractTo(): Invalid or unitialized Zip object
--- I am trying to move servers, without being able to unzip it will make life a lot harder :(
am...@adnry.com <am...@adnry.com> #3
Thank you.
wa...@gmail.com <wa...@gmail.com> #5
di...@formitize.com <di...@formitize.com> #6
tl;dr; don't use compression with zips if you want to unzip.
It's unfortunate but it works for me at least
wa...@gmail.com <wa...@gmail.com> #7
di...@formitize.com <di...@formitize.com> #8
wa...@gmail.com <wa...@gmail.com> #9
I figured worth a try with the new php55 runtime with the new in-memory tempnam() support.
No luck, still came up with the same error:
PHP Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Could not close zip file vfs://root/temp/foo5500f0e3a3c002.77893406.'
This really hinders being able to add features to the deployed app. I'd love to be able to generate excel reports out of the data in the DB :)
di...@formitize.com <di...@formitize.com> #10
ha...@gmail.com <ha...@gmail.com> #11
ha...@gmail.com <ha...@gmail.com> #12
ha...@gmail.com <ha...@gmail.com> #13
It uses the zip library (zip.lib.php) in phpmyadmin.
You should remove the following code before using it.
if (! defined('PHPMYADMIN')) {
exit;
}
The parameters of the method "addFile" is different from ZipArchive.
function addFile($data, $name, $time = 0){
......
}
finally, it provides file() method to output binary data rather than save to a file.
If you really need to generate a zip file, just use following code:
$zipContent = $zip->file(); //$zip = new ZipFile();
$options = ['gs' => ['Content-Type' => 'application/zip']];
$ctx = stream_context_create($options);
file_put_contents('gs://your_bucket/some_path/filename.zip', $zipContent, 0, $ctx);
gr...@gmail.com <gr...@gmail.com> #14
di...@formitize.com <di...@formitize.com> #15
I have a feeling its due to SEEK_END not going to the end of the file
I don't like using PclZip, it works decent in most cases but it can be very time consuming unzipping files, and they might not always unzip due to compression rules.
[Deleted User] <[Deleted User]> #16
$filename = "gs://whatever/test.zip";
$zip = new ZipArchive();
if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$zip->addFromString('file.txt', "some random data"); //returns true
$zip->numFiles; // = 1
$zip->close(); // returns false
echo $zip->getStatusString(); //returns Failure to create temporary file: Read-only file system
[Deleted User] <[Deleted User]> #17
bg...@gmail.com <bg...@gmail.com> #18
[Deleted User] <[Deleted User]> #19
ap...@dilemmapuzzles.com <ap...@dilemmapuzzles.com> #20
[Deleted User] <[Deleted User]> #21
i'm trying to make it work for phpexcel..... which require for create and read...
i didn't manage to go far though... sigh
wa...@gmail.com <wa...@gmail.com> #22
[Deleted User] <[Deleted User]> #23
that's my way of handling it for now....
so far, ziparchiever is the only road block for me
wa...@gmail.com <wa...@gmail.com> #24
[Deleted User] <[Deleted User]> #25
di...@formitize.com <di...@formitize.com> #26
And yes, I am pretty disappointed with the lack of speed for resolving unzipping, I had to set up an annoying process where it will send all zips to another hosting provider, unzip there and then upload all the unzipped files back. And sometimes it fails because the other server just can't keep up so had to set up many more checks :(
*I now use GO to unzip.
[Deleted User] <[Deleted User]> #27
it will be great if you share some guide
sl...@google.com <sl...@google.com> #28
Unfortunately the root cause of the issue is the way that sandboxing works in GAE - some extensions get confused when they cannot access files using libc apis. The way streams work in PHP (i.e. gs:// and vfs://) does not compose well with most PECL extensions.
di...@formitize.com <di...@formitize.com> #29
It might be better if you figure out how to use it based on instructions here, so you can add it to other readers manually.
[Deleted User] <[Deleted User]> #30
- same price point as GAE
- it require minimum 1 instance
its cheaper to use other provider than google computing for now
[Deleted User] <[Deleted User]> #31
i did try and it only work half way....
when i try "getFromName"....it fail flawlessly....
i just give up and use another server to process it and return as array into task queue
di...@formitize.com <di...@formitize.com> #32
Also make sure your using the PCLZip I've attached earlier in
th...@1492.io <th...@1492.io> #33
But on "big" zip, we got gzinflate() data error.
On little ones, no troubles.
di...@formitize.com <di...@formitize.com> #34
[Deleted User] <[Deleted User]> #35
Basically it involves using the built-in compression mechanics of the Cloud Storage engine and some custom hacks to this archive:
This is not tested at any extent, but the principle works. As long as you tell Cloud Storage that the file is compressed, it will return this file uncompressed when requesting the file in the future.
In the blobstore viewer in the App Engine developer console the file still get downloaded compressed. But it works as intended in any other context.
Guess splitbrain/php-archive should be able to solve other issues around Google App Engine and ZIP-archives.
[Deleted User] <[Deleted User]> #36
wa...@gmail.com <wa...@gmail.com> #37
[Deleted User] <[Deleted User]> #38
Guess we'll have to wait and in the mean time, hope our customers don't notice when ZIPs are not created every time heh
jo...@gmail.com <jo...@gmail.com> #39
I finally had to switch to OpenTBS for excel file generation as it operates in memory and therefore get around this issue.
Jo...@thp.org <Jo...@thp.org> #40
Jo...@thp.org <Jo...@thp.org> #41
All I need is a routine that will zip up a folder of files from cloud storage - not big ones - it could all be done in memory - but what's the easiest and simplest way to make this work??
I've put my semi-failed attempt at
Jo...@thp.org <Jo...@thp.org> #42
[Deleted User] <[Deleted User]> #43
Of course this doesn't work without a minor but nasty hack to the code. Disabling the CRC32 check for the liberary. Just search for it in the file called ZipAbstractEntry.php. Reason that this fails is apprently a difference between 64bit platforms and 32bit platformns in the function crc32(). This should probably be fixed at the source.
[Deleted User] <[Deleted User]> #44
Jo...@thp.org <Jo...@thp.org> #45
Environment now?
John Coonrod | Executive Vice President | The Hunger Project
*1634 Eye St NW, Suite 1100, Washington, DC 20006*
T: +1-202-552-3008 | M: +1-917-209-9505 |
On Mon, Nov 6, 2017 at 4:17 AM, <buganizer-system@google.com> wrote:
[Deleted User] <[Deleted User]> #46
cr...@gmail.com <cr...@gmail.com> #47
Jo...@thp.org <Jo...@thp.org> #48
[Deleted User] <[Deleted User]> #49
is...@google.com <is...@google.com>
cc...@gmail.com <cc...@gmail.com> #50
Jo...@thp.org <Jo...@thp.org> #51
for the work I need to do - creating and reading xlsx files on the tmp
drive - it works.
John Coonrod, PhD | Executive Vice President | The Hunger Project
1634 Eye St NW, Suite 1100, Washington, DC 20006
T: +1-202-552-3008 | M: +1-917-209-9505 |
On Fri, May 24, 2019 at 10:17 AM <buganizer-system@google.com> wrote:
cc...@gmail.com <cc...@gmail.com> #52
photos. Time to do some testing on 7.2.
On Fri, May 24, 2019 at 10:13 AM <buganizer-system@google.com> wrote:
dd...@google.com <dd...@google.com> #53
This is no longer an issue that requires a fix. If you observe that this issue still persists or you have any other issues, feel free to open a new entry.
This entry will now be closed.
Best regards.
ju...@gmail.com <ju...@gmail.com> #54
rm...@mostmedia.com <rm...@mostmedia.com> #55
Jo...@thp.org <Jo...@thp.org> #56
to work fine on PHP7 (once you refactor your app to give up all those
lovely built-in features in php5.5!)
John Coonrod, PhD | Executive Vice President | The Hunger Project
1634 Eye St NW, Suite 1100, Washington, DC 20006
T: +1-202-552-3008 | M: +1-917-209-9505 |
On Thu, Feb 20, 2020 at 8:02 PM <buganizer-system@google.com> wrote:
gi...@girishgupta.com <gi...@girishgupta.com> #57
This still doesn't appear to be fixed on PHP 7.3. I get the same issues as above on $zip->close();
where $zip = new ZipArchive;
. (In between I open()
, addFromString()
, etc.
I tried the Ne-Lexa/php-zip
solution but my files must be too big?
Thanks!
Girish
Jo...@thp.org <Jo...@thp.org> #58
John Coonrod, PhD | Executive Vice President | The Hunger Project,
Washington, DC
Coordinator and co-founder, Movement for Community-led Development
M: +1-917-209-9505 | *New resource! *
On Sun, Apr 26, 2020 at 2:33 AM <buganizer-system@google.com> wrote:
gi...@girishgupta.com <gi...@girishgupta.com> #59
Thanks, John. Sadly, I have the same issue in PHP 7.2:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$ProjectID = "XXX";
require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$client = new StorageClient(['projectId' => $ProjectID]);
$client->registerStreamWrapper();
$zip = new ZipArchive;
if ($zip->open("gs://".$ProjectID.".appspot.com/tests/test.zip", ZipArchive::CREATE) === TRUE)
{
echo "Opened zip file.<br><br>";
$zip->addFromString("test.txt", "XXXXXXX");
}
$zip->close();
The issue isn't with the link to Storage as I'm using fopen()
, etc., just fine to create files there.
Curiously, I'm told that the ZIP file is being created but then the error comes on closing it. (No ZIP file is created in Storage.)
Opened zip file
Warning: ZipArchive::close(): Failure to create temporary file: No such file or directory in /srv/test.php on line 25
I'd hugely appreciate any help. Thank you!
Jo...@thp.org <Jo...@thp.org> #60
then moved them. I suspect that should work better for you.
John Coonrod, PhD | Executive Vice President | The Hunger Project,
Washington, DC
Coordinator and co-founder, Movement for Community-led Development
M: +1-917-209-9505 | *New resource! *
On Sun, Apr 26, 2020 at 9:33 PM <buganizer-system@google.com> wrote:
gi...@girishgupta.com <gi...@girishgupta.com> #61
Thanks. Would you mind sharing the code for how you did that, please? That sounds like it could work but I don't understand the mechanism of a "temp area."
Thank you!
Girish
Jo...@thp.org <Jo...@thp.org> #62
It's a simple script to create and download an xlsx file (which is really
just a zip file). Lines 74 onward are what you want. At line 91 you could
put your cloud storage copying code. Personally, I like to think of cloud
storage more like a tape drive and less like a local disk!
John Coonrod, PhD | Executive Vice President | The Hunger Project,
Washington, DC
Coordinator and co-founder, Movement for Community-led Development
M: +1-917-209-9505 | *New resource! *
On Sun, Apr 26, 2020 at 11:34 PM <buganizer-system@google.com> wrote:
gi...@girishgupta.com <gi...@girishgupta.com> #63
John, thank you so much! This works perfectly! I appreciate your very precise instructions.
Here's my code for anyone else who may find it useful (including the "proper" way of doing this commented out for when the issue is finally fixed!):
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$ProjectID = "XXX";
require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$client = new StorageClient(['projectId' => $ProjectID]);
$client->registerStreamWrapper();
// $zip = new ZipArchive;
// if ($zip->open("gs://".$ProjectID.".appspot.com/tests/test.zip", ZipArchive::CREATE) === TRUE)
// {
// echo "Opened zip file.<br><br>";
// $zip->addFromString("test.txt", "Tetgdfgdgfgd fg sdf gsdf ");
// }
// $zip->close();
$fname = "test.zip";
$dir = sys_get_temp_dir();
$tmp = tempnam($dir, $fname);
$zip = new ZipArchive;
$zip->open($tmp,ZipArchive::CREATE);
$zip->addFromString("test1.txt", "Contents of file 1.");
$zip->addFromString("test2.txt", "Contents of file 2.");
$zip->close();
copy($tmp, "gs://".$ProjectID.".appspot.com/tests/".$fname);
ad...@gmail.com <ad...@gmail.com> #64
Error not detectable (No ZIP file is created in Storage.)
Opened zip file
Warning: ZipArchive::close(): Failure to create temporary file: No such file or directory in /srv/test.php on line 25
Description
$zip = new ZipArchive();
$zip->open("gs://whatever/somethig.zip", ZipArchive::OVERWRITE); //returns true
$zip->addFromString('file.txt', "some random data"); //returns true
$zip->numFiles; // = 1
$zip->close(); // returns false
$zip->getStatusString(); //returns Failure to create temporary file: Read-only file system
I expect that it will be writable, it actually is with file_set_content call or whatever file writing functions i use. I tried the same code with a couple of variations:
1.already existing zip file;
2.not existing zip file;
3.ZipArchive::CREATE as a second parameter of the ZipArchive::open call
4.Using ZipArchive::addFile to add the file from cloud storage
Maybe it tries to create a temporary file on some other place not on the cloud storage. The same code is working in the development environment.