A
A
Andrey Surzhikov2018-07-20 17:19:11
Yandex.Disk
Andrey Surzhikov, 2018-07-20 17:19:11

WebDAV Ya.Disk and Flysystem: why directories are created but files are not copied?

I use Flysystem in Laravel.
The task is to copy the file from local storage to Ya.Disk via WebDAV.
Problem: when you try to transfer a file, the necessary directories are created on the Yandex disk, but the files themselves are not copied ..

use Sabre\DAV\Client as WebDAVClient;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\WebDAV\WebDAVAdapter as WebDAVAdapter;
use League\Flysystem\MountManager;

....

$manager = new MountManager();
$local = new Filesystem(new LocalAdapter(storage_path()));
$manager->mountFilesystem('local', $local);

$webdav_adapter = new WebDAVAdapter(
  new WebDAVClient([
    'baseUri'    => 'https://webdav.yandex.ru',
    'userName'   => env('YANDEX_DISK_LOGIN'),
    'password'   => env('YANDEX_DISK_PASSWORD'),
  ])
, '/');
$webdav = new Filesystem($webdav_adapter);
$manager->mountFilesystem('webdav', $webdav);

....

$local_path = 'local://' . 'app/public/dicoms/1.dcm';
$cloud_path = 'webdav://' . 'archive/12345/dicoms/1.dcm';
$res = $manager->copy( $local_path, $cloud_path );

Based on the results of execution, an empty folder "archive/12345/dicoms/" is created on Yandex.Disk

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2018-09-30
@AaAAxzz

There is a normal adapter for Flysystem (only it works through rest-api ... but for flysystem)
https://github.com/jack-theripper/yandex-disk-flysystem

O
Ogoun Er, 2018-07-20
@Ogoun

It is better not to use YaDisk, the official documentation does not correspond to the real API, the developers change the API without backward compatibility and warning. Communication with technical support leads to nothing.
Here you can see an example of an attempt to communicate with support on a similar issue.

V
Vladislav Nagorny, 2018-07-20
@esvils

https://github.com/nixsolutions/yandex-php-library...
+
https://laravel.com/docs/5.6/filesystem#custom-fil...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question