/** * Uploads a file from your local machine to specified folder / subfolder on Saaspose storage. * * @param string $strFile * @param string $strFolder */ public function uploadFile($strFile, $strFolder = '') { try { $strRemotefileName = basename($strFile); $strURIRequest = $this->strURIFile; if ($strFolder == "") { $strURIRequest .= $strRemotefileName; } else { $strURIRequest .= $strFolder . "/" . $strRemotefileName; } $signedURI = Utils::sign($strURIRequest); return Utils::uploadFileBinary($signedURI, $strFile); } catch (Exception $e) { throw new Exception($e->getMessage()); } }
/** * Convert Document to different file format without using storage * $param string $inputPath * @param string $outputPath * @param string $outputFormat */ public function convertLocalFile($inputPath = "", $outputPath = "", $outputFormat = "") { try { //check whether file is set or not if ($inputPath == "") { throw new Exception("No file name specified"); } if ($outputFormat == "") { throw new Exception("output format not specified"); } $strURI = Product::$baseProductUri . "/words/convert?format=" . $outputFormat; if (!file_exists($inputPath)) { throw new Exception("input file doesn't exist."); } $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, "xml"); $v_output = Utils::validateOutput($responseStream); if ($v_output === "") { if ($outputFormat == "html") { $save_format = "zip"; } else { $save_format = $outputFormat; } if ($outputPath == "") { $outputPath = Utils::getFileName($inputPath) . "." . $save_format; } Utils::saveFile($responseStream, SaasposeApp::$outputLocation . $outputPath); return true; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }