Answer the question
In order to leave comments, you need to log in
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 );
Answer the question
In order to leave comments, you need to log in
There is a normal adapter for Flysystem (only it works through rest-api ... but for flysystem)
https://github.com/jack-theripper/yandex-disk-flysystem
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.
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 questionAsk a Question
731 491 924 answers to any question