//Obtaining all Metadata for file try { $docInfo = $docApi->GetDocumentMetadata($clientId, $fileId); //Selecting file names if ($docInfo->status == "Ok") { //Obtaining file name for entered file Id $name = $docInfo->result->last_view->document->name; } else { throw new Exception($docInfo->error_message); } //###Make a request to Storage Api for dowloading file //Obtaining file stream of downloading file and definition of folder where to download file $outFileStream = FileStream::fromHttp(dirname(__FILE__) . '/../temp', $name); //Downlaoding of file try { $file = $storageApi->GetFile($clientId, $fileId, $outFileStream); if ($file->downloadDirectory != "" && isset($file)) { //If request was successfull - set message variable for template $message = '<font color="green">File was downloaded to the <font color="blue">' . $outFileStream->downloadDirectory . '</font> folder</font> <br />'; F3::set('message', $message); } else { throw new Exception("Something wrong with entered data"); } } catch (Exception $e) { $error = 'ERROR: ' . $e->getMessage() . "\n"; F3::set('error', $error); } } catch (Exception $e) { $error = 'ERROR: ' . $e->getMessage() . "\n"; F3::set('error', $error); }
//Get file guid $guid = $jobInfo->result->inputs[0]->outputs[0]->guid; F3::set('fileId', $guid); //Get file name $name = $jobInfo->result->inputs[0]->outputs[0]->name; //Local path to the downloads folder $downloadFolder = dirname(__FILE__) . '/../downloads'; //Check is folder exist if (!file_exists($downloadFolder)) { //If folder don't exist create it mkdir($downloadFolder); } //Obtaining file stream of downloading file and definition of folder where to download file $outFileStream = FileStream::fromHttp($downloadFolder, $name); //Download file from GroupDocs. $download = $storageApi->GetFile($clientId, $guid, $outFileStream); F3::set("message", "File was converted and downloaded to the " . $downloadFolder . "/" . $name); //### If request was successfull //Generation of iframe URL using $pageImage->result->guid //iframe to prodaction server if ($basePath == "https://api.groupdocs.com/v2.0") { $iframe = 'https://apps.groupdocs.com/document-viewer/embed/' . $guid; //iframe to dev server } elseif ($basePath == "https://dev-api-groupdocs.dynabic.com/v2.0") { $iframe = 'https://dev-apps-groupdocs.dynabic.com/document-viewer/embed/' . $guid; //iframe to test server } elseif ($basePath == "https://stage-api-groupdocs.dynabic.com/v2.0") { $iframe = 'https://stage-apps-groupdocs.dynabic.com/document-viewer/embed/' . $guid; } elseif ($basePath == "http://realtime-api.groupdocs.com") { $iframe = 'http://realtime-apps.groupdocs.com/document-viewer/embed/' . $guid; }