src/libraries/controllers/ApiPhotoController.php
/**
    * Replace the binary image file and the associated hash
    * This method does not take any additional parameters
    *   call the update API to update meta data
    *
    * @param string $id ID of the photo to be updated.
    * @return string Standard JSON envelope
    */
Replace the binary image file and the associated hash
This method does not take any additional parameters
call the update API to update meta data

@param string $id ID of the photo to be updated.
@return string Standard JSON envelope
Replace the binary image file and the associated hash This method does not take any additional parameters call the update API to update meta data @param string $id ID of the photo to be updated . @return string Standard JSON envelope
public function replace($id)
  {
    getAuthentication()->requireAuthentication();
    getAuthentication()->requireCrumb();
    $attributes = $_GET;
    extract($this->parsePhotoFromRequest());
    $hash = sha1_file($localFile);
    $allowDuplicate = $this->config->site->allowDuplicate;
    if(isset($attributes['allowDuplicate']))
      $allowDuplicate = $attributes['allowDuplicate'];
    if($allowDuplicate == '0')
    {
      $hashResp = $this->api->invoke("/{$this->apiVersion}/photos/list.json", EpiRoute::httpGet, array('_GET' => array('hash' => $hash)));
      if($hashResp['result'][0]['totalRows'] > 0)
        return $this->conflict('This photo already exists based on a sha1 hash. To allow duplicates pass in allowDuplicate=1', false);
    }
    if(!isset($attributes['allowAutoRotate']) || $attributes['allowAutoRotate'] != '0')
    {
      $exiftran = $this->config->modules->exiftran;
      if(is_executable($exiftran))
        exec(sprintf('%s -ai %s', $exiftran, escapeshellarg($localFile)));
    }
    $status = $this->photo->replace($id, $localFile, $name);
    if(!$status)
      return $this->error('Could not complete the replacement of the photo', false);
    $photoResp = $this->api->invoke("/photo/{$id}/view.json", EpiRoute::httpGet);
    return $this->success('yes', $photoResp['result']);
  }
public function replace ( $ id ) { getAuthentication ( ) -> requireAuthentication ( ) ; getAuthentication ( ) -> requireCrumb ( ) ; $ attributes = $ _GET ; extract ( $ this -> parsePhotoFromRequest ( ) ) ; $ hash = sha1_file ( $ localFile ) ; $ allowDuplicate = $ this -> config -> site -> allowDuplicate ; if ( isset ( $ attributes [ 'allowDuplicate' ] ) ) $ allowDuplicate = $ attributes [ 'allowDuplicate' ] ; if ( $ allowDuplicate == '0' ) { $ hashResp = $ this -> api -> invoke ( " / { $ this -> apiVersion } /photos/list.json " , EpiRoute :: httpGet , array ( '_GET' => array ( 'hash' => $ hash ) ) ) ; if ( $ hashResp [ 'result' ] [ 0 ] [ 'totalRows' ] > 0 ) return $ this -> conflict ( 'This photo already exists based on a sha1 hash. To allow duplicates pass in allowDuplicate=1' , false ) ; } if ( ! isset ( $ attributes [ 'allowAutoRotate' ] ) || $ attributes [ 'allowAutoRotate' ] != '0' ) { $ exiftran = $ this -> config -> modules -> exiftran ; if ( is_executable ( $ exiftran ) ) exec ( sprintf ( '%s -ai %s' , $ exiftran , escapeshellarg ( $ localFile ) ) ) ; } $ status = $ this -> photo -> replace ( $ id , $ localFile , $ name ) ; if ( ! $ status ) return $ this -> error ( 'Could not complete the replacement of the photo' , false ) ; $ photoResp = $ this -> api -> invoke ( " /photo/ { $ id } /view.json " , EpiRoute :: httpGet ) ; return $ this -> success ( 'yes' , $ photoResp [ 'result' ] ) ; }
Replace the binary image file and the associated hash
 This method does not take any additional parameters
   call the update API to update meta data
Replace the binary image file and the associated hash This method does not take any additional parameters call the update API to update meta data
// this determines where to get the photo from and populates $localFile and $name // auto rotation is enabled by default but requires exiftran