@@ -80,6 +80,14 @@ public function usingNewDavPath() {
8080 $ this ->usingOldDavPath = false ;
8181 }
8282
83+ /**
84+ * @Given /^using new public dav path$/
85+ */
86+ public function usingNewPublicDavPath () {
87+ $ this ->davPath = 'public.php/dav ' ;
88+ $ this ->usingOldDavPath = false ;
89+ }
90+
8391 public function getDavFilesPath ($ user ) {
8492 if ($ this ->usingOldDavPath === true ) {
8593 return $ this ->davPath ;
@@ -270,6 +278,42 @@ public function downloadingFile($fileName) {
270278 }
271279 }
272280
281+ /**
282+ * @When Downloading public file :filename
283+ */
284+ public function downloadingPublicFile (string $ filename ) {
285+ $ token = $ this ->lastShareData ->data ->token ;
286+ $ fullUrl = substr ($ this ->baseUrl , 0 , -4 ) . "public.php/dav/files/ $ token/ $ filename " ;
287+
288+ $ client = new GClient ();
289+ $ options = [
290+ 'headers ' => [
291+ 'X-Requested-With ' => 'XMLHttpRequest ' ,
292+ ]
293+ ];
294+
295+ try {
296+ $ this ->response = $ client ->request ('GET ' , $ fullUrl , $ options );
297+ } catch (\GuzzleHttp \Exception \ClientException $ e ) {
298+ $ this ->response = $ e ->getResponse ();
299+ }
300+ }
301+
302+ /**
303+ * @When Downloading public file :filename without ajax header
304+ */
305+ public function downloadingPublicFileWithoutHeader (string $ filename ) {
306+ $ token = $ this ->lastShareData ->data ->token ;
307+ $ fullUrl = substr ($ this ->baseUrl , 0 , -4 ) . "public.php/dav/files/ $ token/ $ filename " ;
308+
309+ $ client = new GClient ();
310+ try {
311+ $ this ->response = $ client ->request ('GET ' , $ fullUrl );
312+ } catch (\GuzzleHttp \Exception \ClientException $ e ) {
313+ $ this ->response = $ e ->getResponse ();
314+ }
315+ }
316+
273317 /**
274318 * @Then Downloaded content should start with :start
275319 * @param int $start
0 commit comments