Example #1
0
 /**
  * Do the actual upload of a string file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   string  $mode
  * @return  array   file metadata
  */
 protected function upload($path, $contents, $mode)
 {
     if (!($result = $this->client->uploadFileFromString($this->prefix($path), $mode, $contents))) {
         return false;
     }
     return $this->normalizeObject($result, $path);
 }
Example #2
0
 /**
  * Do the actual upload of a string file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   WriteMode  $mode
  * @return  array|false   file metadata
  */
 protected function upload($path, $contents, WriteMode $mode)
 {
     $location = $this->applyPathPrefix($path);
     if (!($result = $this->client->uploadFileFromString($location, $mode, $contents))) {
         return false;
     }
     return $this->normalizeObject($result, $path);
 }
Example #3
0
function crearCarpeta($folio, $tipo = "PREVIO")
{
    $empresaSes = str_replace(" ", "_", $_SESSION["empresa"]);
    global $cliente_id;
    //cliente de dropbox
    try {
        $appInfo = dbx\AppInfo::loadFromJsonFile("../includes/Dropbox/config.json");
        $accessToken = "jxxJCQnl2ykAAAAAAAAAGRmgdiFo8REFSCcJ-sb19QyT2lPiEEV8g7GiyB2booGP";
        // desde la pagina de app console
        $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
        $root = "/examenes";
        $empresa = "/" . $empresaSes;
        $folder = "/" . $folio;
        //este va a ser el folio del paciente
        $path = $root . $empresa . $folder;
        //creamos el folder
        $createFolder = $dbxClient->createFolder($path);
        //subimos los archivos si se creó el folder
        if ($createFolder) {
            if ($cliente_id == 479) {
                $files_root = "../archivos";
                $files_emp = "/{$empresaSes}";
                $files_type = "/{$tipo}";
                $files_path = $files_root . $files_emp . $files_type;
                foreach (scandir($files_path) as $d) {
                    if ($d == "." || $d == "..") {
                        continue;
                    }
                    $archivos[] = array("filename" => $path . "/" . $d, "file" => file_get_contents("{$files_path}/{$d}"));
                }
            } else {
                switch ($tipo) {
                    case 'PREVIO':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Radiografias.xlsx")));
                        break;
                    case 'STAFF':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Radiografias.xlsx")));
                        break;
                    case 'OPERARIO':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Audiometria.xlsx")), array("filename" => $path . "/Fuerza_Equilibrio.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Radiografias.xlsx")));
                        break;
                    default:
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Radiografias.xlsx")));
                        break;
                }
            }
            foreach ($archivos as $d) {
                $dbxClient->uploadFileFromString($d["filename"], dbx\WriteMode::add(), $d["file"]);
            }
        }
    } catch (Exception $e) {
    }
}
Example #4
0
 /**
  * @return bool
  */
 public function send()
 {
     $sent = true;
     $files = $this->backup->getFilesTobackup();
     foreach ($files as $file => $name) {
         $file = fopen($file, 'r');
         $upload = $this->dropbox->uploadFile($this->folder . '/' . $name, \Dropbox\WriteMode::force(), $file);
         if (!$upload) {
             $sent = false;
             echo 'DROPBOX upload manqu�e de ' . $file . ' vers ' . $this->folder . $name;
         }
     }
     $streams = $this->backup->getStreamsTobackup();
     foreach ($streams as $stream => $name) {
         $upload = $this->dropbox->uploadFileFromString($this->folder . '/' . $name, \Dropbox\WriteMode::force(), $stream);
         if (!$upload) {
             $sent = false;
             echo 'DROPBOX upload manqu�e de ' . $file . ' vers ' . $this->folder . $name;
         }
     }
     return $sent;
 }
Example #5
0
    $empresa = "/" . $empresaSes;
    $folder = "/" . $folio;
    //este va a ser el folio del paciente
    $path = $root . $empresa . $folder;
    //creamos el folder
    $createFolder = $dbxClient->createFolder($path);
    //subimos los archivos si se creó el folder
    if ($createFolder) {
        switch ($tipo) {
            case 'PREVIO':
                $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/PREVIO/Radiografias.xlsx")));
                break;
            case 'STAFF':
                $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/STAFF/Radiografias.xlsx")));
                break;
            case 'OPERARIO':
                echo "archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx";
                $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Audiometria.xlsx")), array("filename" => $path . "/Fuerza_Equilibrio.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/OPERARIO/Radiografias.xlsx")));
                break;
            default:
                $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("archivos/{$empresaSes}/Radiografias.xlsx")));
                break;
        }
        foreach ($archivos as $d) {
            $dbxClient->uploadFileFromString($d["filename"], dbx\WriteMode::add(), $d["file"]);
        }
    }
}
?>
</body>
</html>