public function testMergeZipArchives() { $zip_1 = Zip::create(__DIR__ . '/../tmp/test_manager_5.zip'); $zip_1->add(__DIR__ . '/../resources/lorem.txt')->close(); $zip_2 = Zip::create(__DIR__ . '/../tmp/test_manager_6.zip'); $zip_2->add(__DIR__ . '/../resources/keepcalm.png')->close(); $manager = new ZipManager(); $addZip = $manager->addZip(Zip::open(__DIR__ . '/../tmp/test_manager_5.zip'))->addZip(Zip::open(__DIR__ . '/../tmp/test_manager_6.zip')); $merge = $manager->merge(__DIR__ . '/../tmp/test_manager_merge.zip'); $this->assertTrue($merge); $manager->close(); }
public function testDelete() { $zip = Zip::open(__DIR__ . '/../tmp/test_3.zip'); $zip->delete('keepcalm.png'); $this->assertInstanceOf('\\Comodojo\\Zip\\Zip', $zip); $close = $zip->close(); $this->assertTrue($close); }
/** * Add files to zip * * @param $path string * @param $files array * @throws \Comodojo\Exception\ZipException */ public function add($path, $files) { $zip = \Comodojo\Zip\Zip::open($path); $zip->add($files); }
public function notesupload() { $chapterid = Input::get('chapteruuid'); $file = Input::file('notes'); $notes = Notes::where('chapter_id', $chapterid)->first(); if (!$notes) { $notes = new Notes(); $notes->id = Uuid::generate(); $notes->chapter_id = $chapterid; $notes->file_path = public_path() . "/notes/"; } $notes->file_name = $file->getClientOriginalName(); $notes->save(); if ($file->isValid()) { $fileName = $notes->chapter_id . ".zip"; /* if(env('APP_ENV')==="production"){//give write permission chmod($notes->file_path, 0777); }*/ $file->move($notes->file_path, $fileName); //\Storage::disk('notes')->put($fileName,File::get($file)); //$filePath=storage_path()."/thinkmerit/notes/"; $zip = \Comodojo\Zip\Zip::open($notes->file_path . $fileName); $zip->extract($notes->file_path . $chapterid); $notes->save(); $zip->close(); unlink($notes->file_path . $fileName); /*if(env('APP_ENV')==="production"){//exclude write permission chmod($notes->file_path, 0444); }*/ //\Storage::disk('notes')->delete($fileName); return back()->withErrors(['success' => "File successfully uploaded!"]); } return back()->withErrors(['error' => "Error uploading file!"]); }