yandex_disk v0.1.2 YandexDisk.File View Source
Link to this section Summary
Functions
Copy file from one folder to another. Return error if destination file already exists.
Pass overwrite: true
to overwrite existing file.
Upload file to yandex disk
Delete file. You can pass permanently: true
to remove file totally. By default file is placed
into Trash.
Download file from yandex disk
Get list of all files
Move file from one folder to another. Return error if destination file already exists.
Pass overwrite: true
to overwrite existing file.
Get recent files
Update metainfo about file
Link to this section Functions
copy(client, args)
View Sourcecopy(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Copy file from one folder to another. Return error if destination file already exists.
Pass overwrite: true
to overwrite existing file.
Examples
iex> YandexDisk.File.copy(client, from: "disk:/test/test11.mp4", to: "disk:/test/test_folder4/test11.mp4")
{:ok,
%{
"href" => "https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2Ftest%2Ftest_folder4%2Ftest11.mp4",
"method" => "GET",
"templated" => false
}}
iex> YandexDisk.File.copy(client, from: "disk:/test/test11.mp4", to: "disk:/test/test_folder4/test11.mp4")
{:error, "DiskResourceAlreadyExistsError",
"Resource "disk:/test/test_folder4/test11.mp4" already exists."}
iex> YandexDisk.File.copy(client, from: "disk:/test/test11.mp4", to: "disk:/test/test_folder4/test11.mp4", overwrite: true)
{:ok,
%{
"href" => "https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2Ftest%2Ftest_folder4%2Ftest11.mp4",
"method" => "GET",
"templated" => false
}}
See:
create(client, args)
View Sourcecreate(YandexDisk.client(), Keyword.t()) :: YandexDisk.success_result_info() | YandexDisk.error_result()
Upload file to yandex disk
Examples
iex> YandexDisk.File.create(client, yandex_path: "disk:/test/test11_001.mp4", file: "/private/tmp/test11.mp4")
{:ok,
%{
"href" => "https://uploader2o.disk.yandex.net:443/upload-target/20190721T171019.178.utd.2qnk7i2o1a71pt1gi51vm6f1d-k2o.29535254",
"method" => "PUT",
"operation_id" => "d49adcad60fa0727bf2b8607289a22271961d1e883bbe2041c5c3902758ce27d",
"templated" => false
}}
iex> YandexDisk.File.create(client, yandex_path: "disk:/test/test11_001.mp4", file: "/private/tmp/test11.mp4")
{:error, "DiskResourceAlreadyExistsError", "Resource "disk:/test/test11_001.mp4" already exists."}
iex> YandexDisk.File.create(client, yandex_path: "disk:/test/test11_001.mp4", file: "/private/tmp/test11.mp4", overwrite: true)
{:ok,
%{
"href" => "https://uploader10j.disk.yandex.net:443/upload-target/20190721T171800.768.utd.91am4kjo1bucv1s0b5am7ruze-k10j.11648544",
"method" => "PUT",
"operation_id" => "e6db5ed3880c1dc5e62a085f44d6d0b1eb20fa9a8d8d0404dc7275b8e197d431",
"templated" => false
}}
See:
destroy(client, args)
View Sourcedestroy(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.url()} | {:ok, :ok} | YandexDisk.error_result()
Delete file. You can pass permanently: true
to remove file totally. By default file is placed
into Trash.
Examples
iex> YandexDisk.File.destroy(client, yandex_path: "disk:/test/test11_001.mp4")
{ :ok, :ok }
iex> YandexDisk.File.destroy(client, yandex_path: "disk:/test/not_existing.mp4")
{ :error, "DiskNotFoundError", "Resource not found." }
See:
get(client, list)
View Sourceget(YandexDisk.client(), yandex_path: String.t(), file: String.t()) :: {:ok}
Download file from yandex disk
Examples
iex> YandexDisk.File.create(client, yandex_path: "disk:/test/test11_001.mp4", file: "/private/tmp/test11.mp4")
{:ok,
%{
"href" => "https://uploader2o.disk.yandex.net:443/upload-target/20190721T171019.178.utd.2qnk7i2o1a71pt1gi51vm6f1d-k2o.29535254",
"method" => "PUT",
"operation_id" => "d49adcad60fa0727bf2b8607289a22271961d1e883bbe2041c5c3902758ce27d",
"templated" => false
}}
iex> YandexDisk.File.create(client, yandex_path: "disk:/test/test11_001.mp4", file: "/private/tmp/test11.mp4")
{:error, "DiskResourceAlreadyExistsError", "Resource "disk:/test/test11_001.mp4" already exists."}
iex> YandexDisk.File.create(client, yandex_path: "disk:/test/test11_001.mp4", file: "/private/tmp/test11.mp4", overwrite: true)
{:ok,
%{
"href" => "https://uploader10j.disk.yandex.net:443/upload-target/20190721T171800.768.utd.91am4kjo1bucv1s0b5am7ruze-k10j.11648544",
"method" => "PUT",
"operation_id" => "e6db5ed3880c1dc5e62a085f44d6d0b1eb20fa9a8d8d0404dc7275b8e197d431",
"templated" => false
}}
See:
index(client, args \\ [])
View Sourceindex(YandexDisk.client(), Keyword.t()) :: {:ok, offset :: integer(), YandexDisk.info()} | YandexDisk.error_result()
Get list of all files
Examples
iex> YandexDisk.File.index(client, limit: 3, fields: "items.name, items.media_type")
{:ok, 0,
[
%{"media_type" => "compressed", "name" => "DICOM.zip"},
%{"media_type" => "audio", "name" => "IM1"},
%{"media_type" => "audio", "name" => "IM101"}
]}
See:
move(client, args)
View Sourcemove(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Move file from one folder to another. Return error if destination file already exists.
Pass overwrite: true
to overwrite existing file.
Examples
iex> YandexDisk.Folder.move(client, from: "disk:/test/test_folder4", to: "disk:/test/test_folder6")
{:ok,
%{
"href" => "https://cloud-api.yandex.net/v1/disk/operations/xxxxx",
"method" => "GET",
"templated" => false
}}
iex> YandexDisk.Folder.move(client, from: "disk:/test/test_folder4", to: "disk:/test/test_folder6")
{:error, "DiskNotFoundError", "Resource not found."}
See:
recent(client, args \\ [])
View Sourcerecent(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Get recent files
Examples
iex> YandexDisk.File.recent(client, limit: 3, media_type: "video", fields: "items.name, items.md5")
{:ok, [%{"md5" => "46243e8d863a41077e242cfa1abca138", "name" => "test11.mp4"}]}
iex> YandexDisk.File.recent(client, limit: 3, fields: "items.name, items.md5")
{:ok,
[
%{
"md5" => "847b40a8802815fe4305675d85cd7700",
"name" => "NVR_Camera 1_01_20190719071122.264"
},
%{
"md5" => "01273a2910a9a578b112471602762749",
"name" => "NVR_Camera 1_01_20190719071041.264"
},
%{
"md5" => "a987e7b4e894e5406e118180a92e1512",
"name" => "NVR_Camera 1_01_20190719071001.264"
}
]}
See:
update(client, args)
View Sourceupdate(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Update metainfo about file
Examples
iex> YandexDisk.File.update(client, yandex_path: "disk:/test/test11_001.mp4", custom_properties: %{:foo => :bar}, fields: "custom_properties, path")
{:ok,
%{
"custom_properties" => %{"foo" => "bar"},
"path" => "disk:/test/test11_001.mp4"
}}
iex> YandexDisk.File.update(client, yandex_path: "disk:/test/not_existing.mp4", custom_properties: %{:foo => :bar})
{ :error, "DiskNotFoundError", "Resource not found." }
See: