Skip to content

Commit

Permalink
Getting metadata of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
davicente committed May 29, 2017
1 parent 6528ef3 commit 1047c78
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/Adapter/OneDriveAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ public function getMetadata($path)
return $flysystemMetadata->toArray();
}


/**
* @param string $fileId
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function getFileMetadata($fileId)
{
$response = $this->client->getFileMetadata($fileId);
$responseContent = json_decode((string) $response->getBody());
return $responseContent;
}


/**
* @param FlysystemMetadata $flysystemMetadata
* @param \StdClass $responseContent
Expand Down
29 changes: 27 additions & 2 deletions src/Client/OneDriveClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ public function getMetadata($path)
return $this->getResponse('GET', $url);
}


/**
* @param string $fileId
*
* @return \Psr\Http\Message\ResponseInterface
*
* @link https://dev.onedrive.com/items/get.htm
*/
public function getFileMetadata($fileId) {
$url = self::BASE_URI.$this->getPathFileMetadata($fileId);

return $this->getResponse('GET', $url);
}


/**
* @return \Psr\Http\Message\ResponseInterface
*
Expand Down Expand Up @@ -463,15 +478,25 @@ private function getPathUnderRootDrive($path)
}

/**
* @param string $path
*
* @return string
*/
private function getPathUserDriveMetadata()
{
return 'drive';
}


/**
* @param string $fileId
*
* @return string path to get file metadata
*/
private function getPathFileMetadata($fileId)
{
return 'drive/items/'.$fileId;
}


/**
* @param string $method
* @param string $path
Expand Down

0 comments on commit 1047c78

Please sign in to comment.