0

I am going to make an app. But i am stuck in one issue. I am unable to find in which file of nextcloud, the codes are available which uploads file. i want to find the file in which file uploading codes are situated.

I am going to make an app which will make a duplicate of uploaded file and will save in same directory with slightly changed name.

LEDfan
  • 175
  • 1
  • 2
  • 17
  • This is rather brief, and so consequently is unclear. Maybe Nextcloud users would know what you are referring to, but I'd recommend adding some code or config to your question (using the formatting tools provided) to make it clearer. It may be put on hold in its present state. – halfer Aug 15 '17 at 09:15
  • @halfer My Question was . In NextCloud. Which file has the script to upload files. Means in source files Which file has File uploading codes. Like move_uploaded_file(); I hope now you understood. – Muhammad Baber Zaman Aug 15 '17 at 13:55

1 Answers1

0

The public API for handling files lives in the \OCP\Files namespace, the implementation is in the \OC\Files namespace (https://github.com/nextcloud/server/tree/master/lib/private/Files).

Rather than modifying this code you should use the hooks functionality (never use classes or functions in the \OC\* namespace!): https://docs.nextcloud.com/server/12/developer_manual/app/hooks.html. This way you can execute your own code when a file is created or updated etc.

I guess you need the postWrite hook. Some sample code (untested):

\OC::$server->getRootFolder()->listen('\OC\Files', 'postWrite', function(\OCP\Files\Node $node) {
    $node->copy('my/path');
});
LEDfan
  • 175
  • 1
  • 2
  • 17