qnap-file_station 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +493 -0
- data/Rakefile +8 -0
- data/lib/qnap/file_station.rb +187 -0
- data/qnap-file_station.gemspec +13 -0
- data/test/test_file_station.rb +10 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: afd92ae3b99527ea64cb659f422cf54e8f4e3b04
|
4
|
+
data.tar.gz: 06665735be81179b757a10b1d980013eef0232b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c1ee4272265edcbed969ea1f7d93e1e628bb38568cc29723b89f0b6493aab5f4f9df27270a69b42812d75a009b7c03489dd5ad278a4a23cbf16b8e717617bc1
|
7
|
+
data.tar.gz: 3a88ad3757fabce25d6ad8a80b7619921fc290c9a46be98125ce1eea302ecd1247ad318df9d0914024a17fc2e20650bd3925a05ec397b46461aec125a11678a9
|
data/README.md
ADDED
@@ -0,0 +1,493 @@
|
|
1
|
+
Qnap::FileStation
|
2
|
+
=======
|
3
|
+
|
4
|
+
This gem provides an interface to the File Station app that comes installed by default on many QNAP NAS.
|
5
|
+
|
6
|
+
It provides access to all available endpoints, but the documentation is patchy and untested. Use with caution.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
-------
|
10
|
+
|
11
|
+
`gem install qnap-file_station`
|
12
|
+
|
13
|
+
Usage
|
14
|
+
-------
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'qnap/file_station'
|
18
|
+
|
19
|
+
fs = Qnap::FileStation.new '192.168.1.100', 'username', 'password'
|
20
|
+
fs.createdir dest_folder: "", dest_path: ""
|
21
|
+
contents = fs.get_extract_list extract_file: "my_zip_file.zip"
|
22
|
+
fs.logout
|
23
|
+
```
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# Alternative syntax to guarantee logout
|
27
|
+
|
28
|
+
Qnap::FileStation.session('192.168.1.100', 'username', 'password') do |fs|
|
29
|
+
# Show contents of the recycle bin
|
30
|
+
pp fs.get_tree node: "recycle_root"
|
31
|
+
# logout is automatically called, even if there was an exception
|
32
|
+
end
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
Available methods
|
37
|
+
|
38
|
+
### createdir
|
39
|
+
Create a folder in the specified path.
|
40
|
+
|
41
|
+
#### Parameters
|
42
|
+
Key | Description
|
43
|
+
--- | ---
|
44
|
+
dest_folder | Folder name
|
45
|
+
dest_path | Path of the folder
|
46
|
+
|
47
|
+
### rename
|
48
|
+
Rename a folder or file in the specified path.
|
49
|
+
|
50
|
+
#### Parameters
|
51
|
+
Key | Description
|
52
|
+
--- | ---
|
53
|
+
sid | Input sid for authentication
|
54
|
+
path | Path of the folder/ file
|
55
|
+
source_name | Current folder/ file name to be changed
|
56
|
+
dest_name | New folder/ file name
|
57
|
+
|
58
|
+
### copy
|
59
|
+
Copy a file/folder from the source to the destination.
|
60
|
+
|
61
|
+
#### Parameters
|
62
|
+
Key | Description
|
63
|
+
--- | ---
|
64
|
+
source_file | Name of the copied file/folder
|
65
|
+
source_total | Total number of copied files/folders
|
66
|
+
source_path | Source path of the copied file/folder
|
67
|
+
dest_path | Destination of the copied file/folder
|
68
|
+
mode | 1: skip, 0: overwrite
|
69
|
+
dup | The duplication file name when copying the same destination with source files/folders.
|
70
|
+
|
71
|
+
### move
|
72
|
+
Move a file/folder from the source to the destination.
|
73
|
+
|
74
|
+
#### Parameters
|
75
|
+
Key | Description
|
76
|
+
--- | ---
|
77
|
+
source_file | Name of the copied file/folder
|
78
|
+
source_total | Total number of copied files/folders
|
79
|
+
source_path | Source path of the copied file/folder
|
80
|
+
dest_path | Destination of the copied file/folder
|
81
|
+
mode | 1: skip, 0: overwrite
|
82
|
+
|
83
|
+
### get_extract_list
|
84
|
+
List the content of a zipped file.
|
85
|
+
|
86
|
+
#### Parameters
|
87
|
+
Key | Description
|
88
|
+
--- | ---
|
89
|
+
extract_file | Path of the extracted file
|
90
|
+
code_page | Extracting code page (UTF-8 only)
|
91
|
+
start | Start number of the listed contents
|
92
|
+
limit | Total number of the listed contents
|
93
|
+
sort | Sorting type (filename, file_size, compress_size, mt)
|
94
|
+
dir | List type (ASC, DESC)
|
95
|
+
|
96
|
+
### extract
|
97
|
+
Extract files from a zipped file to the specified path on NAS. This is an asynchronous API. The caller can use the returned process ID (pid) for further operations.
|
98
|
+
|
99
|
+
#### Parameters
|
100
|
+
Key | Description
|
101
|
+
--- | ---
|
102
|
+
extract_file | Path of the extracted files
|
103
|
+
code_page | Extracting code page (UTF-8 only)
|
104
|
+
dest_path | Destination of the extracted files
|
105
|
+
pwd | Extraction password (can be null)
|
106
|
+
mode | Extraction mode (extract_all, extract_part)
|
107
|
+
overwrite | 1: overwrite, 0: skip
|
108
|
+
path_mode | full: extract file with full path none: don't extract file with full path
|
109
|
+
code_page | Extracting code page (UTF-8 only) If mode is extract_part
|
110
|
+
part_file | Name of the file to be extracted (can be more than one)
|
111
|
+
part_total | The total number of extracted files
|
112
|
+
|
113
|
+
### cancel_extract
|
114
|
+
Cancel the extraction process by process ID.
|
115
|
+
|
116
|
+
#### Parameters
|
117
|
+
Key | Description
|
118
|
+
--- | ---
|
119
|
+
pid | Pid of the extracting process
|
120
|
+
|
121
|
+
### compress
|
122
|
+
Compress files to a specified file on NAS. This is an asynchronous API. The caller can use the returned process ID (pid) for further operations.
|
123
|
+
|
124
|
+
#### Parameters
|
125
|
+
Key | Description
|
126
|
+
--- | ---
|
127
|
+
extract_file | Path of the extracted files
|
128
|
+
compress_name | The compressed name
|
129
|
+
type | Compressed format type (7z/zip)(default:zip)
|
130
|
+
pwd | The compressed password (can be null)
|
131
|
+
level | Compressed level (normal/large/fast) (default:normal)
|
132
|
+
encryipt | 7z:AES256, zip:ZipCrypto/AES256 (can be null)
|
133
|
+
path | The compressed file path
|
134
|
+
total | The amount of compression files number
|
135
|
+
compress_file | The compressed file name
|
136
|
+
|
137
|
+
### cancel_compress
|
138
|
+
Cancel the compressing process by process ID.
|
139
|
+
|
140
|
+
#### Parameters
|
141
|
+
Key | Description
|
142
|
+
--- | ---
|
143
|
+
pid | Pid of the compressing process
|
144
|
+
|
145
|
+
### get_compress_status
|
146
|
+
Get the compressing status by process ID.
|
147
|
+
|
148
|
+
#### Parameters
|
149
|
+
Key | Description
|
150
|
+
--- | ---
|
151
|
+
pid | Pid of the compressing process
|
152
|
+
|
153
|
+
### download
|
154
|
+
Download a file, a folder, or multiple files as a zip file, a compressed file, or just the same as they are.
|
155
|
+
|
156
|
+
#### Parameters
|
157
|
+
Key | Description
|
158
|
+
--- | ---
|
159
|
+
isfolder | The request file is a folder. 1: yes, 0: no.
|
160
|
+
compress | If the request file is a folder or files then<br>0/1: zip archive only, 2: compress files.<br>else the request file is a single file then<br>0: transfer the original file to client<br>1: zip archive only<br>2: compress files<br>
|
161
|
+
source_path | Path of the file. Start with the share name.
|
162
|
+
source_file | File name.
|
163
|
+
source_total | Total number of files.
|
164
|
+
|
165
|
+
### get_thumb
|
166
|
+
Get a size-specified thumbnail of an image file.
|
167
|
+
|
168
|
+
#### Parameters
|
169
|
+
Key | Description
|
170
|
+
--- | ---
|
171
|
+
path | Path of the file. Start with the share name.
|
172
|
+
name | File name.
|
173
|
+
size | 80/320/640; default value:320
|
174
|
+
|
175
|
+
### upload
|
176
|
+
Upload a file.
|
177
|
+
|
178
|
+
#### Parameters
|
179
|
+
Key | Description
|
180
|
+
--- | ---
|
181
|
+
type | standard
|
182
|
+
dest_path | Destination dir path
|
183
|
+
overwrite | 1: overwrite, 0: skip
|
184
|
+
progress | Destination file path, "/" needs to be replaced with "-"
|
185
|
+
|
186
|
+
### get_viewer
|
187
|
+
Open a multimedia file stream for viewing or playing.
|
188
|
+
|
189
|
+
#### Parameters
|
190
|
+
Key | Description
|
191
|
+
--- | ---
|
192
|
+
func | open
|
193
|
+
source_path | Source dir path
|
194
|
+
source_file | Source file name
|
195
|
+
player | Use the
|
196
|
+
rtt | 1:FLV for video or music, 3:MP3 for music
|
197
|
+
format | Video transcode format type for opening. jwplayer player or not (1/0)
|
198
|
+
format | can be : mp4_360 / mp4_720 / flv_720
|
199
|
+
|
200
|
+
### get_tree
|
201
|
+
Get folder list in a folder, a shared iso, the shared root folder, or the recycle bin.
|
202
|
+
|
203
|
+
#### Parameters
|
204
|
+
Key | Description
|
205
|
+
--- | ---
|
206
|
+
is_iso | Is a iso share. 1: yes, 0: no. Default is 0. This value is according to a field "iconCls" in get_tree response. If "iconCls" is "iso", this value is 1.
|
207
|
+
node | Target folder path. Use folder path to get folder list, and use the value with "share_root" to get share list, or use the value with "recycle_root" to get recycle bin share list.
|
208
|
+
|
209
|
+
### get_list
|
210
|
+
Retrieve both file and folder list in a specified folder or a shared iso, with filters such as response record count, file type..., etc.
|
211
|
+
|
212
|
+
#### Parameters
|
213
|
+
Key | Description
|
214
|
+
--- | ---
|
215
|
+
is_iso | Is a iso share. 1: yes, 0: no
|
216
|
+
list_mode | Value is "all"
|
217
|
+
path | Folder path
|
218
|
+
dir | Sorting direction. ASC: Ascending , DESC: Descending
|
219
|
+
limit | Number of response datas
|
220
|
+
sort | Sort field (filename/filesize/filetype/mt/privilege/owner/group)
|
221
|
+
start | Response data start index
|
222
|
+
hidden_file | List hidden file or not. 0:donnot list hidden files, 1:list files
|
223
|
+
type | 1: MUSIC, 2:VIDEO, 3:PHOTO (1/2/3)
|
224
|
+
mp4_360 | Video format type mp4_360 true or not(1/0)
|
225
|
+
mp4_720 | Video format type mp4_720 true or not(1/0)
|
226
|
+
flv_720 | Video format type flv_720 true or not(1/0)
|
227
|
+
filename | Search video file name
|
228
|
+
|
229
|
+
### get_file_size
|
230
|
+
Get total files size in a specified path. The size counting includes hidden file and folder.
|
231
|
+
|
232
|
+
#### Parameters
|
233
|
+
Key | Description
|
234
|
+
--- | ---
|
235
|
+
path | Folder path
|
236
|
+
total | The number of file/folder which are calculating the total size
|
237
|
+
name | file or folder name
|
238
|
+
|
239
|
+
### delete
|
240
|
+
Delete folder(s)/file(s) in a specified path.
|
241
|
+
|
242
|
+
#### Parameters
|
243
|
+
Key | Description
|
244
|
+
--- | ---
|
245
|
+
path | Folder path.
|
246
|
+
file_total | Total number of folder/file(s).
|
247
|
+
file_name | Folder/file name.
|
248
|
+
|
249
|
+
### stat
|
250
|
+
Get status of folder(s)/file(s), such as file size, privilege..., etc.
|
251
|
+
|
252
|
+
#### Parameters
|
253
|
+
Key | Description
|
254
|
+
--- | ---
|
255
|
+
path | Folder path.
|
256
|
+
file_total | Total number of folder/file(s).
|
257
|
+
file_name | Folder/file name.
|
258
|
+
|
259
|
+
### stat
|
260
|
+
Set folder(s)/file(s) modification time.
|
261
|
+
|
262
|
+
#### Parameters
|
263
|
+
Key | Description
|
264
|
+
--- | ---
|
265
|
+
path | Folder path.
|
266
|
+
file_total | Total number of folder/file(s).
|
267
|
+
file_name | Folder/file name.
|
268
|
+
settime | 1: set modification time
|
269
|
+
timestamp | Epoch time (seconds since 1970-01-01 00:00:00 UTC).<br>The modification time will be set current datetime on the server if not specified.
|
270
|
+
|
271
|
+
### search
|
272
|
+
Search file/folder by key word within a specified path.
|
273
|
+
|
274
|
+
#### Parameters
|
275
|
+
Key | Description
|
276
|
+
--- | ---
|
277
|
+
is_iso | Is a iso share. 1: yes, 0: no
|
278
|
+
keyword | keyword
|
279
|
+
source_path | Folder path
|
280
|
+
dir | Sorting direction. ASC: Ascending , DESC: Descending
|
281
|
+
limit | Number of response data
|
282
|
+
sort | Sort field (filename/filesize/filetype/mt/privilege/owner/group)
|
283
|
+
start | Response data start index
|
284
|
+
|
285
|
+
###
|
286
|
+
Download a shared file by an unique ID (ssid).
|
287
|
+
|
288
|
+
#### Parameters
|
289
|
+
Key | Description
|
290
|
+
--- | ---
|
291
|
+
uniqe_id | Use the unique id to download the shared file.
|
292
|
+
|
293
|
+
### get_share_link
|
294
|
+
Create share links of specified files, and retrieve or email the links to someone.
|
295
|
+
|
296
|
+
#### Parameters
|
297
|
+
Key | Description
|
298
|
+
--- | ---
|
299
|
+
network_type | internet: from network, local: from local
|
300
|
+
download_type | create_download_link: create download link, email_download_link: email download link
|
301
|
+
valid_duration | specific_time: specific the download time, period_of_time: time period, forever: forver download load
|
302
|
+
hostname | host IP or domain name
|
303
|
+
day | shared day time if valid_duration=period_of_time
|
304
|
+
hour | shared hour time if valid_duration=period_of_time
|
305
|
+
file_total | shared datetime if valid_duration=specific_time
|
306
|
+
file_name | 0(zero) if valid_duration=forever
|
307
|
+
path | download file path
|
308
|
+
ssl | enabled ssl
|
309
|
+
access_enabled | enable access code
|
310
|
+
access_code | access code
|
311
|
+
include_access_code | email contents include access code or not
|
312
|
+
addressee | get email addressee
|
313
|
+
subject | get email subject
|
314
|
+
content | get email content
|
315
|
+
|
316
|
+
### share_file
|
317
|
+
Create share link and email to someone.
|
318
|
+
|
319
|
+
#### Parameters
|
320
|
+
Key | Description
|
321
|
+
--- | ---
|
322
|
+
network_type | internet: from network, local: from local
|
323
|
+
download_type | create_download_link: create download link, email_download_link: email download link
|
324
|
+
valid_duration | specific_time: specific the download time, period_of_time: time period, forever: forver download load
|
325
|
+
hostname | host IP or domain name
|
326
|
+
day | shared day time if valid_duration=period_of_time
|
327
|
+
hour | shared hour time if valid_duration=period_of_time
|
328
|
+
file_total | shared datetime if valid_duration=specific_time
|
329
|
+
file_name | 0(zero) if valid_duration=forever
|
330
|
+
path | download file path
|
331
|
+
ssl | enabled ssl
|
332
|
+
access_enabled | enable access code
|
333
|
+
access_code | access code
|
334
|
+
include_access_code | email contents include access code or not
|
335
|
+
addressee | get email addressee
|
336
|
+
subject | get email subject
|
337
|
+
content | get email content
|
338
|
+
link_url | internet: from network, local: from local
|
339
|
+
mail_content_date | mail contents for valid date information
|
340
|
+
mail_content_pwd | mail contents for password information
|
341
|
+
expire_time | expire time(seconds)
|
342
|
+
|
343
|
+
### get_share_list
|
344
|
+
Get whole shared file list.
|
345
|
+
|
346
|
+
#### Parameters
|
347
|
+
Key | Description
|
348
|
+
--- | ---
|
349
|
+
dir | Sorting direction. ASC: Ascending , DESC: Descending
|
350
|
+
limit | Number of response data
|
351
|
+
sort | Sort field (filename/filesize/filetype/mt/privilege/owner/group)
|
352
|
+
start | Response data start index
|
353
|
+
|
354
|
+
### get_domain_ip_list
|
355
|
+
Get hostname and external IP address of the NAS.
|
356
|
+
|
357
|
+
|
358
|
+
### delete_share
|
359
|
+
Stop specified file(s) sharing.
|
360
|
+
|
361
|
+
#### Parameters
|
362
|
+
Key | Description
|
363
|
+
--- | ---
|
364
|
+
file_total | number of total files
|
365
|
+
download_link | link url
|
366
|
+
filename | shared file
|
367
|
+
|
368
|
+
### delete_share_all
|
369
|
+
Stop all file sharing.
|
370
|
+
|
371
|
+
|
372
|
+
### update_share_link
|
373
|
+
Update the attributes of specified share links.
|
374
|
+
|
375
|
+
#### Parameters
|
376
|
+
Key | Description
|
377
|
+
--- | ---
|
378
|
+
download_type | create_download_link: create download link, email_download_link: email download link
|
379
|
+
valid_duration | specific_time: specific the download time,<br>period_of_time: time period,<br>forever: forver download load
|
380
|
+
hostname | host IP or domain name
|
381
|
+
datetime | expire sharing time
|
382
|
+
file_total | shared datetime if valid_duration=specific_time
|
383
|
+
ssl | enabled ssl
|
384
|
+
access_enabled | enable access code
|
385
|
+
access_code | access code
|
386
|
+
ssids | the ssid of shared files
|
387
|
+
|
388
|
+
### get_tree
|
389
|
+
Retrieve recycle bin tree list. 2
|
390
|
+
|
391
|
+
#### Parameters
|
392
|
+
Key | Description
|
393
|
+
--- | ---
|
394
|
+
node | Recycle Bin node name (${node}=recycle_root)
|
395
|
+
|
396
|
+
### trash_recovery
|
397
|
+
Recovery specified files in recycle bin. This is an asynchronous API. The caller can use the returned process ID (pid) for further operations.
|
398
|
+
|
399
|
+
#### Parameters
|
400
|
+
Key | Description
|
401
|
+
--- | ---
|
402
|
+
source_file | Name of the copied file/folder
|
403
|
+
source_total | Total number of the recovery trash files
|
404
|
+
source_path | Source path of the trash
|
405
|
+
mode | 1: skip, 0: overwrite
|
406
|
+
source_file | trash file
|
407
|
+
source_file | ....
|
408
|
+
|
409
|
+
### cancel_trash_recovery
|
410
|
+
Cancel recycle bin recovery process by process ID.
|
411
|
+
|
412
|
+
#### Parameters
|
413
|
+
Key | Description
|
414
|
+
--- | ---
|
415
|
+
pid | Pid of the recycle bin recovery process
|
416
|
+
|
417
|
+
### delete
|
418
|
+
Empty the recycle bin.
|
419
|
+
|
420
|
+
#### Parameters
|
421
|
+
Key | Description
|
422
|
+
--- | ---
|
423
|
+
path | The path folder name of recycle bin
|
424
|
+
file_name | Same as the value ${path}
|
425
|
+
|
426
|
+
### video_ml_queue
|
427
|
+
Retrieve the status of media library transcoding queue.
|
428
|
+
|
429
|
+
#### Parameters
|
430
|
+
Key | Description
|
431
|
+
--- | ---
|
432
|
+
op | 1: transcoding queue lists
|
433
|
+
subop | 0: wait status<br>1: finish status<br>2: error<br>3: ongoing<br>4: all
|
434
|
+
|
435
|
+
### video_ml_queue
|
436
|
+
Add or delete files in the media library transcoding queue.
|
437
|
+
|
438
|
+
#### Parameters
|
439
|
+
Key | Description
|
440
|
+
--- | ---
|
441
|
+
op | Operation
|
442
|
+
subop | Sub-operation
|
443
|
+
total | The amount of filenames.
|
444
|
+
path | The opration path name.
|
445
|
+
filename | filename
|
446
|
+
|
447
|
+
### video_list
|
448
|
+
Get media library transcode files list.
|
449
|
+
|
450
|
+
#### Parameters
|
451
|
+
Key | Description
|
452
|
+
--- | ---
|
453
|
+
source_path | Source file path
|
454
|
+
source_total | The source file total number for ${source_file}
|
455
|
+
source_file | Source file name
|
456
|
+
|
457
|
+
### video_ml_status
|
458
|
+
Get media library files transcode status.
|
459
|
+
|
460
|
+
#### Parameters
|
461
|
+
Key | Description
|
462
|
+
--- | ---
|
463
|
+
path | Source file path
|
464
|
+
total | The source file total number for ${source_file}
|
465
|
+
filename | Source file name
|
466
|
+
|
467
|
+
### delete_transcode
|
468
|
+
Delete the media transcode or image files.
|
469
|
+
|
470
|
+
#### Parameters
|
471
|
+
Key | Description
|
472
|
+
--- | ---
|
473
|
+
path | Folder path.
|
474
|
+
file_total | Total number of folder/file(s).
|
475
|
+
file_name | Folder/file name.
|
476
|
+
mode | 1: delete image files<br>2: delete transcode video files<br>3: delete image and transcode video files.
|
477
|
+
keep_trans | 0: delete transcode files in "@Transcode" folder<br>1: do not delete transcode files in "@Transcode" folder
|
478
|
+
|
479
|
+
### get_video_qstatus
|
480
|
+
Get transcode file status.
|
481
|
+
|
482
|
+
#### Parameters
|
483
|
+
Key | Description
|
484
|
+
--- | ---
|
485
|
+
pid | Video transcoding process id.
|
486
|
+
|
487
|
+
### cancel_transcode
|
488
|
+
Cancel transcoding process.
|
489
|
+
|
490
|
+
#### Parameters
|
491
|
+
Key | Description
|
492
|
+
--- | ---
|
493
|
+
pid | Video transcoding process id.
|
data/Rakefile
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
require 'openssl'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
module Qnap
|
7
|
+
class FileStation
|
8
|
+
PROTOCOL = 'https'
|
9
|
+
API_METHODS = {
|
10
|
+
cancel_compress: [:pid],
|
11
|
+
cancel_extract: [:pid],
|
12
|
+
cancel_transcode: [:pid],
|
13
|
+
cancel_trash_recovery: [:pid],
|
14
|
+
compress: [:compress_file, :compress_name, :encryipt, :level, :pwd, :total, :type],
|
15
|
+
copy: [:dest_path, :dup, :mode, :source_file, :source_path, :source_total],
|
16
|
+
createdir: [:dest_folder, :dest_path],
|
17
|
+
delete: [:file_name, :file_total, :path],
|
18
|
+
delete_share: [:download_link, :file_total, :filename],
|
19
|
+
delete_share_all: [],
|
20
|
+
delete_transcode: [:file_name, :file_total, :keep_trans, :mode, :path],
|
21
|
+
download: [:compress, :isfolder, :source_file, :source_path, :source_total],
|
22
|
+
extract: [:code_page, :dest_path, :extract_file, :mode, :overwrite, :path_mode, :pwd],
|
23
|
+
get_compress_status: [:pid],
|
24
|
+
get_domain_ip_list: [],
|
25
|
+
get_extract_list: [:code_page, :dir, :extract_file, :limit, :path, :sort, :start],
|
26
|
+
get_file_size: [:name, :name, :path, :total],
|
27
|
+
get_list: [:dir, :filename, :flv_720, :hidden_file, :is_iso, :limit, :list_mode, :mp4_360, :mp4_720, :path, :sort, :start, :type],
|
28
|
+
get_share_link: [:access_code, :access_enabled, :addressee, :content, :day, :download_type, :file_name, :file_total, :hostname, :hour, :include_access_code, :network_type, :path, :ssl, :subject, :valid_duration],
|
29
|
+
get_share_list: [:dir, :limit, :sort, :start],
|
30
|
+
get_thumb: [:name, :path, :size],
|
31
|
+
get_tree: [:is_iso, :node],
|
32
|
+
get_video_qstatus: [:pid],
|
33
|
+
move: [:mode, :source_file, :source_path, :source_total],
|
34
|
+
rename: [:dest_name, :path, :source_name],
|
35
|
+
search: [:dir, :keyword, :limit, :sort, :source_path, :start],
|
36
|
+
share_file: [:access_code, :access_enabled, :addressee, :content, :day, :dowdownload_type, :expire_time, :file_name, :file_total, :hostname, :hour, :include_access_code, :link_url, :mail_content_date, :mail_content_pwd, :network_type, :path, :ssl, :subject, :valid_duration],
|
37
|
+
stat: [:file_name, :file_total, :mtime, :path, :settime],
|
38
|
+
trash_recovery: [:mode, :source_file, :source_path, :source_total],
|
39
|
+
update_share_link: [:access_code, :access_enabled, :datetime, :dowdownload_type, :file_total, :hostname, :ssids, :ssl, :valid_duration],
|
40
|
+
upload: [:dest_path, :overwrite, :progress, :type],
|
41
|
+
video_list: [:source_path, :source_total],
|
42
|
+
video_ml_queue: [:filename, :op, :path, :subop, :total],
|
43
|
+
video_ml_status: [:filename, :path, :total],
|
44
|
+
}
|
45
|
+
|
46
|
+
def self.session(*args)
|
47
|
+
ds = self.new *args
|
48
|
+
begin
|
49
|
+
yield ds
|
50
|
+
ensure
|
51
|
+
ds.logout
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
API_METHODS.each do |method_name, fields|
|
56
|
+
|
57
|
+
next if method_defined? method_name
|
58
|
+
|
59
|
+
define_method method_name, Proc.new { |params={}|
|
60
|
+
if (diff = fields - params.keys).count > 0
|
61
|
+
puts "Missing keys: #{diff}"
|
62
|
+
end
|
63
|
+
|
64
|
+
if (diff = params.keys - fields).count > 0
|
65
|
+
puts "Extra keys: #{diff}"
|
66
|
+
end
|
67
|
+
|
68
|
+
despatch_query @url, params.merge(func: method_name, sid: get_sid)
|
69
|
+
}
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
def login(params={})
|
74
|
+
despatch_query(
|
75
|
+
"#{PROTOCOL}://#{@host}/cgi-bin/filemanager/wfm2Login.cgi",
|
76
|
+
params
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def logout(params={})
|
81
|
+
return unless @sid
|
82
|
+
despatch_query(
|
83
|
+
"#{PROTOCOL}://#{@host}/cgi-bin/filemanager/wfm2Logout.cgi",
|
84
|
+
params.merge(sid: @sid)
|
85
|
+
)
|
86
|
+
@sid = nil
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_sid
|
90
|
+
@sid ||= login(user: @username, pwd: Base64.encode64(@password).strip)[:sid]
|
91
|
+
end
|
92
|
+
|
93
|
+
def initialize(host, username, password)
|
94
|
+
@host = host
|
95
|
+
@username = username
|
96
|
+
@password = password
|
97
|
+
@sid = nil
|
98
|
+
@url = "#{PROTOCOL}://#{@host}/cgi-bin/filemanager/utilRequest.cgi"
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def despatch_query(url, params)
|
104
|
+
uri = URI url
|
105
|
+
uri.query = URI.encode_www_form(params) if params.keys.length > 0
|
106
|
+
req = Net::HTTP::Get.new uri
|
107
|
+
|
108
|
+
response = Net::HTTP.start(
|
109
|
+
uri.host,
|
110
|
+
uri.port,
|
111
|
+
use_ssl: PROTOCOL == 'https',
|
112
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE
|
113
|
+
) do |https|
|
114
|
+
https.request req
|
115
|
+
end
|
116
|
+
|
117
|
+
unless (200..299).include? response.code.to_i
|
118
|
+
raise RuntimeError.new "Error response from #{uri} -> #{response.read_body}"
|
119
|
+
end
|
120
|
+
|
121
|
+
unless response['content-type'] =~ /application\/json/
|
122
|
+
raise "Don't know how to parse #{response['content-type']}"
|
123
|
+
end
|
124
|
+
|
125
|
+
data = JSON.parse response.read_body, symbolize_names: true
|
126
|
+
|
127
|
+
if data.respond_to?(:key?) and data.key?(:status) and data[:status] != 1
|
128
|
+
raise RuntimeError.new "Error response from #{uri} -> #{data}"
|
129
|
+
end
|
130
|
+
|
131
|
+
data
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
__END__
|
137
|
+
Error code, Token, Description
|
138
|
+
0 WFM2_FAIL UNKNOWN ERROR
|
139
|
+
1 WFM2_DONE SUCCESS
|
140
|
+
1 WFM2_SUCCESS SUCCESS
|
141
|
+
2 WFM2_FILE_EXIST FILE EXIST
|
142
|
+
3 WFM2_AUTH_FAIL Authentication Failure
|
143
|
+
4 WFM2_PERMISSION_DENY Permission Denied
|
144
|
+
5 WFM2_FILE_NO_EXIST FILE/FOLDER NOT EXIST
|
145
|
+
5 WFM2_SRC_FILE_NO_EXIST FILE/FOLDER NOT EXIST
|
146
|
+
6 WFM2_EXTRACTING FILE EXTRACTING
|
147
|
+
7 WFM2_OPEN_FILE_FAIL FILE IO ERROR
|
148
|
+
8 WFM2_DISABLE Web File Manager is not enabled.
|
149
|
+
9 WFM2_QUOTA_ERROR You have reached the disk quota limit.
|
150
|
+
10 WFM2_SRC_PERMISSION_DENY You do not have permission to perform this action.
|
151
|
+
11 WFM2_DES_PERMISSION_DENY You do not have permission to perform this action.
|
152
|
+
12 WFM2_ILLEGAL_NAME " + = / \ : | * ? < > ; [ ] % , ` '
|
153
|
+
13 WFM2_EXCEED_ISO_MAX The maximum number of allowed ISO shares is 256. Please unmount an ISO share
|
154
|
+
14 WFM2_EXCEED_SHARE_MAX The maximum number of shares is going to be exceeded.
|
155
|
+
15 WFM2_NEED_CHECK
|
156
|
+
16 WFM2_RECYCLE_BIN_NOT_ENABLE
|
157
|
+
17 WFM2_CHECK_PASSWORD_FAIL Enter password
|
158
|
+
18 WFM2_VIDEO_TCS_DISABLE
|
159
|
+
19 WFM2_DB_FAIL The system is currently busy. Please try again later.
|
160
|
+
19 WFM2_DB_QUERY_FAIL The system is currently busy. Please try again later.
|
161
|
+
20 WFM2_PARAMETER_ERROR There were input errors. Please try again later.
|
162
|
+
21 WFM2_DEMO_SITE Your files are now being transcoded.
|
163
|
+
22 WFM2_TRANSCODE_ONGOING Your files are now being transcoded.
|
164
|
+
23 WFM2_SRC_VOLUME_ERROR An error occurred in the source file. Please check and try again later.
|
165
|
+
24 WFM2_DES_VOLUME_ERROR A write error has occurred at the target destination. Please check and try again
|
166
|
+
25 WFM2_DES_FILE_NO_EXIST The target destination is unavailable. Please check and try again later.
|
167
|
+
26 WFM2_FILE_NAME_TOO_LONG 255 byte limit exceeded
|
168
|
+
27 WFM2_FOLDER_ENCRYPTION This folder has been encrypted. Please decrypt it and try again.
|
169
|
+
28 WFM2_PREPARE Processing now
|
170
|
+
29 WFM2_NO_SUPPORT_MEDIA This file format is not supported.
|
171
|
+
30 WFM2_DLNA_QDMS_DISABLE Please enable the DLNA Media Server
|
172
|
+
31 WFM2_RENDER_NOT_FOUND Cannot find any available DLNA devices.
|
173
|
+
32 WFM2_CLOUD_SERVER_ERROR The SmartLink service is currently busy. Please try again later.
|
174
|
+
33 WFM2_NAME_DUP That folder or file name already exists. Please use another name.
|
175
|
+
34 WFM2_EXCEED_SEARCH_MAX 1000
|
176
|
+
35 WFM2_MEMORY_ERROR
|
177
|
+
36 WFM2_COMPRESSING
|
178
|
+
37 WFM2_EXCEED_DAV_MAX
|
179
|
+
38 WFM2_UMOUNT_FAIL
|
180
|
+
39 WFM2_MOUNT_FAIL
|
181
|
+
40 WFM2_WEBDAV_ACCOUNT_PASSWD_ERROR
|
182
|
+
41 WFM2_WEBDAV_SSL_ERROR
|
183
|
+
42 WFM2_WEBDAV_REMOUNT_ERROR
|
184
|
+
43 WFM2_WEBDAV_HOST_ERROR
|
185
|
+
44 WFM2_WEBDAV_TIMEOUT_ERROR
|
186
|
+
45 WFM2_WEBDAV_CONF_ERROR
|
187
|
+
46 WFM2_WEBDAV_BASE_ERROR
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "qnap-file_station"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.date = "2016-09-28"
|
5
|
+
s.summary = "Interface to the File Station API"
|
6
|
+
s.description = "Manage your files and folders in File Station"
|
7
|
+
s.authors = "cyclotron3k"
|
8
|
+
s.files = ["lib/qnap/file_station.rb", "Rakefile", "qnap-file_station.gemspec", "README.md"]
|
9
|
+
s.test_files = ["test/test_file_station.rb"]
|
10
|
+
s.homepage = "https://github.com/cyclotron3k/qnap-file_station"
|
11
|
+
s.license = "MIT"
|
12
|
+
s.required_ruby_version = ">= 1.9.0"
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qnap-file_station
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cyclotron3k
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Manage your files and folders in File Station
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- Rakefile
|
21
|
+
- lib/qnap/file_station.rb
|
22
|
+
- qnap-file_station.gemspec
|
23
|
+
- test/test_file_station.rb
|
24
|
+
homepage: https://github.com/cyclotron3k/qnap-file_station
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.9.0
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.5.1
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Interface to the File Station API
|
48
|
+
test_files:
|
49
|
+
- test/test_file_station.rb
|