yandex_disk v0.1.0 YandexDisk.PublicFile View Source
Link to this section Summary
Functions
Publish file to be accessed from internet
Remove public file. File itself remains on disk.
Generate url for download
Get list of public files
Get metainfo about public file
Save to downloads. Will return error if you does not have Downloads folder.
Link to this section Functions
create(client, args)
View Sourcecreate(YandexDisk.client(), Keyword.t()) :: YandexDisk.success_result_url() | YandexDisk.error_result()
Publish file to be accessed from internet
Examples
iex> YandexDisk.PublicFile.create(client, yandex_path: "disk:/test/test11.mp4") { :ok, "https://cloud-api.yandex.net/v1/disk/resources?path=disk:/test/test11.mp4" }
iex> {:ok, %{"public_url" => public_url}} =
YandexDisk.PublicFile.metadata(client, yandex_path: yandex_path, fields: "public_url")
{:ok, %{"public_url" => "https://yadi.sk/i/OZ9eUNjLMZKlmA"}}
iex> public_url "https://yadi.sk/i/OZ9eUNjLMZKlmA" See:
- https://yandex.ru/dev/disk/api/reference/publish-docpage/#publish
destroy(client, args)
View Sourcedestroy(YandexDisk.client(), Keyword.t()) :: YandexDisk.success_result_url() | YandexDisk.error_result()
Remove public file. File itself remains on disk.
Examples
iex> YandexDisk.PublicFile.destroy(client, yandex_path: "disk:/test/test11.mp4") { :ok, "https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2Ftest%2Ftest11.mp4" }
iex> {:ok, %{}} = YandexDisk.PublicFile.metadata(client, yandex_path: "disk:/test/test11.mp4", fields: "public_url") See:
- https://yandex.ru/dev/disk/api/reference/publish-docpage/#unpublish-q
download_url(client, args)
View Sourcedownload_url(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Generate url for download
Examples
iex> YandexDisk.PublicFile.download_url(client,
public_key: "UloX3BvWzrrNDhOOy9G1JXxPdr+Di7EzKRQ2PX3+y02ssK5RalnfVi34kmMi9SzKq/J6bpmRyOJonT3VoXnDag==")
{:ok,
%{
"href" => "https://downloader.disk.yandex.ru/disk/long_link",
"method" => "GET",
"templated" => false
}}
See:
- https://yandex.ru/dev/disk/api/reference/public-docpage/#download
index(client, args \\ [])
View Sourceindex(YandexDisk.client(), Keyword.t()) :: {:ok, offset :: integer(), list()} | YandexDisk.error_result()
Get list of public files
Examples
iex> YandexDisk.PublicFile.index(client, fields: "items.mime_type, items.md5")
{:ok, 0,
[
%{
"md5" => "66fcbb369769cfd43f897d9f9171fbad",
"mime_type" => "application/octet-stream"
},
%{
"md5" => "3defac315e17c4550655705b9cb53cc9",
"mime_type" => "application/pdf"
},
%{
"md5" => "87abb909d4019c109275b6a5704b5ee9",
"mime_type" => "application/x-zip-compressed"
}
]}
See:
- https://yandex.ru/dev/disk/api/reference/recent-public-docpage/
metadata(client, args)
View Sourcemetadata(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Get metainfo about public file
Examples
iex> YandexDisk.PublicFile.metadata(client,
public_key: "UloX3BvWzrrNDhOOy9G1JXxPdr+Di7EzKRQ2PX3+y02ssK5RalnfVi34kmMi9SzKq/J6bpmRyOJonT3VoXnDag==",
fields: "md5")
{ :ok, %{"md5" => "66fcbb369769cfd43f897d9f9171fbad"} }
iex> YandexDisk.PublicFile.metadata(client, public_key: "UloX3BvWzrrNDhOOy9G1JXxPdr+Di7EzKRQ2PX3", yandex_path: "erere", fields: "md5")
{ :error, "DiskNotFoundError", "Resource not found." }
See:
- https://yandex.ru/dev/disk/api/reference/public-docpage/#meta
save_to_downloads(client, args)
View Sourcesave_to_downloads(YandexDisk.client(), Keyword.t()) :: {:ok, YandexDisk.info()} | YandexDisk.error_result()
Save to downloads. Will return error if you does not have Downloads folder.
Examples
iex> YandexDisk.PublicFile.save_to_downloads(client,
public_key: "UloX3BvWzrrNDhOOy9G1JXxPdr+Di7EzKRQ2PX3+y02ssK5RalnfVi34kmMi9SzKq/J6bpmRyOJonT3VoXnDag==",
name: "nvr1.264")
{ :error, "MethodNotAllowedError", "Method Not Allowed" }
See:
- https://yandex.ru/dev/disk/api/reference/public-docpage/#save