Example #1
0
 /**
  * Define the internal working path, override this method to define.
  */
 public function getTempPath()
 {
     $path = temp_path() . '/uploads';
     if (!FileHelper::isDirectory($path)) {
         FileHelper::makeDirectory($path, 0777, true, true);
     }
     return $path;
 }
Example #2
0
 /**
  * Saves a file
  * @param string $sourcePath An absolute path to a file name to read from.
  * @param string $destinationFileName A file name without a path to save to.
  */
 protected function putFile($sourcePath, $destinationFileName = null)
 {
     if (!$destinationFileName) {
         $destinationFileName = $this->disk_name;
     }
     $destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory();
     if (!FileHelper::isDirectory($destinationPath)) {
         FileHelper::makeDirectory($destinationPath, 0777, true);
     }
     return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName);
 }
 /**
  * Saves a file
  * @param string $sourcePath An absolute local path to a file name to read from.
  * @param string $destinationFileName A storage file name to save to.
  */
 protected function putFile($sourcePath, $destinationFileName = null)
 {
     if (!$destinationFileName) {
         $destinationFileName = $this->disk_name;
     }
     $destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory();
     if (!$this->isLocalStorage()) {
         return $this->copyLocalToStorage($sourcePath, $destinationPath . $destinationFileName);
     }
     /*
      * Using local storage, tack on the root path and work locally
      * this will ensure the correct permissions are used.
      */
     $destinationPath = $this->getLocalRootPath() . '/' . $destinationPath;
     /*
      * Verify the directory exists, if not try to create it. If creation fails
      * because the directory was created by a concurrent process then proceed,
      * otherwise trigger the error.
      */
     if (!FileHelper::isDirectory($destinationPath) && !FileHelper::makeDirectory($destinationPath, 0777, true, true) && !FileHelper::isDirectory($destinationPath)) {
         trigger_error(error_get_last(), E_USER_WARNING);
     }
     return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName);
 }