document); $meta = []; $meta['title'] = sprintf("uri(%s)", rawurlencode(trim($doc->title . " " . $doc->subtitle . " " . $doc->subsubtitle))); $meta['creator'] = "Digital Equipment Corporation"; $meta['description'] = sprintf("uri(%s)", rawurlencode($doc->overview_md())); $doc->load("revisions"); $doc->archive = "P"; $worked = 0; $id = $doc->internal_id; if (Config::get("SANDBOX")) { $id = sprintf("decpdf_test_%s_%08d", $id, time()); } $this->status($id); $doc->load("revisions"); foreach ($doc->revisions as $r) { try { $this->status("Uploading " . $r->filename()); $r->archived = "P"; $r->save(); $this->currentFile = $r->filename(); ArchiveJob::$me = $this; Archive::upload($r->getPDF(), $id, $r->filename(), $meta, [$this, "progress"]); $r->refresh(); $r->archived = "Y"; $r->save(); $worked++; } catch (Exception $e) { $r->refresh(); $r->archived = "F"; $r->save(); $this->fail($e->getMessage()); return; } } if ($worked == 0) { $doc->refresh(); $doc->archived = "F"; $doc->save(); $this->fail("No files uploaded"); return; } else { $doc->refresh(); $doc->archived = "Y"; $doc->archive_url = $id; $doc->save(); } $this->finish(); } public function progress($ch, $todl, $dl, $toul, $ul) { if ($toul > 0) { $txt = sprintf("Uploading %s: %d%%", $this->currentFile, $ul * 100 / $toul); $this->status(sprintf("Uploading %s: %d%%", $this->currentFile, $ul * 100 / $toul)); } } }