ya-disk2
https://github.com/RomiC/ya-disk Original Package: https://www.npmjs.com/package/ya-disk
Original Repo:Yandex Disk API library which provides some methods for working with Yandex.Disk service API. Each method present with each own independent function. Example:
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; ;
Yes, it's callback-based lib. Because it was made to have at least dependencies as possible. If you want you can write you own wrapper based on, i.e. Bluebird library. Example:
;; const infoPromise = ; ;
Installation
npm install --save ya-disk2
Authorization
Each method requires an OAuth token. You can receive one manually or use one of OAuth library, i.e. passport-yandex-token.
List of available methods
download
Downloading a file from the user drive.
link(token, path, [success], [error])
Getting the download link. See details. Example:
;// Thi is lib is neccessary, beacause of Yandex Disk// returns a 302 header when you try to download file// using provided link;;; const API_TOKEN = '1982jhk12h31iad7a(*&kjas';const file = 'disk:/Зима.jpg'; downloadlinkAPI_TOKEN file { const output = ; const req = https; req; req;} consoleerror;
info(token, [succes], [error])
Getting common info about user drive. See details. Example:
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; ;
list(token, [options={}], [success], [error])
Getting a flat list of the user files on the drive. See details.
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; ;
meta
get(token, path, [options={}], [success], [error])
Getting meta-information about the resource (file or directory). See details. Example:
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; meta;
add(token, path, properties, [success], [error])
Append meta information to the resource (file or directory). See details. Example:
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; meta;
operations
Getting operation status. See details. Example:
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas';const operationId = 'MqeRNE6wJFJuKAo7nGAYatqjbUcYo3Hj'; ;
recent(token, [options={}], [success], [error])
Getting a flat list of recently changed files. See details.
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; ;
upload
Tool for uploading a file to the user drive.
link(token, path, [overwrite = false], [success], [error])
Getting link for uploaded file. See details. Example:
;;; ; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; uploadlinkAPI_TOKEN 'disk:/path/to/the/file.txt' true { const fileStream = ; const uploadStream = ; fileStream; fileStream;};
remoteFile(token, url, path, [success], [error])
Upload remote file to the disk by its url. See details. Example:
; const API_TOKEN = '' } = processenv;const url = 'https://tech.yandex.com/disk/doc/dg/yandex-disk-dg.pdf';const path = 'disk:/Приложения/ya-disk2-api/yandex-disk-dg.pdf'; upload;
File and Folder Actions
create(token, path, [success], [error])
Create folder. See details.
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; resources;
remove(token, path, permanently, [success], [error])
Delete file or folder. See details.
; const API_TOKEN = '1982jhk12h31iad7a(*&kjas'; resources;