[owncloud-devel] Find File Full Path

Vincent Petry pvince81 at owncloud.com
Thu Sep 11 08:17:45 GMT 2014


I also didn't find any public API call, it seems that
OC\Files\Filesystem and OC\Files\View are in the private folders.

You can use this:
$fullPath = \OC\Files\Filesystem::getLocalFile($pathRelativeToHome).

Note that this will work only for files that are inside the user's home,
you'll get the full path like
"/var/www/htdocs/owncloud/data/user1/files/subfolder/thefileinquestion.txt"

If the file is on an external storage, for example SMB or FTP, it will
automatically download the file to a temporary location and will return
the path to the temporary file.

So you need to check what you're trying to achieve.

If you're trying to just read the file contents you'd better do it
directly with \OC\Files\Filesystem::fopen($pathRelativeToHome, 'r') as
this will try and stream the file when possible instead of downloading
it. Additionally this will make it work properly with encryption (while
accessing the file directly on disk won't).

Hope this helps.

Vincent

On 09/10/2014 06:03 PM, Sean Bowen-Williams wrote:
> Hey folks,
> 
> I've been looking through the API for a public function call to return
> either the full filepath to the data mount point (/for/example/data/...) or
> get a file's full filepath, not just the owncloud relative filepath.
> 
> I know I'm probably just over looking something simple, but any help would
> be appreciated.
> 
> -Sean
> 
> 
> 
> _______________________________________________
> Devel mailing list
> Devel at owncloud.org
> http://mailman.owncloud.org/mailman/listinfo/devel
> 



More information about the Devel mailing list