but I feel like I would understand it better if I saw an example.
What I want to do is provide a setting where the user can choose a Folder in which they will keep files related to the app. Once they have chosen the folder and I have a Folder object I think I can use getFullPath to get its path in the internal file system. Just not sure how to put this all together.
I made a little progress. I can get an IRootFolder into the page controller constructor via DI and I can find the path of a file within the Nextcloud file system. Is there any way to get the path to Nextcloud storage in the server operating system’s file system so I can combine the two and know the server operating system’s path to a file?
You can get an IRootFolder in your controller, so you can do getUserFolder() to get the Folder object of the given user. Next you can use get() to find a directory or a file in this Folder, you can also use getPath() or getInternalPath();
class TestController extends Controller
{
private $storage;
protected $request;
public function __construct(
string $AppName,
IRequest $request,
IRootFolder $storage,
)
{
parent::__construct($AppName, $request);
$this->storage = $storage;
$this->request = $request;
}
/**
* @NoCSRFRequired
* @NoAdminRequired
*
*/
public function Test()
{
$userFolder = $this->storage->getUserFolder('user name'); //gives you Folder object
$filePath = $userFolder->get('file name')->getPath(); // gives you string
return new DataResponse($filePath);
}