-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathIronBoxDownloadReadyFiles.py
60 lines (53 loc) · 1.88 KB
/
IronBoxDownloadReadyFiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
#---------------------------------------------------
#
# Demonstrates how to download blobs in an IronBox
# container that are in a ready state.
#
# Written by [email protected]
# Website: www.goironbox.com
#
# Usage:
# python IronBoxDownloadReadyFiles.py
#
#---------------------------------------------------
import sys
from IronBoxREST import IronBoxRESTClient
from os.path import join
#---------------------------------------------------
# Your IronBox authentication parameters, you could
# also pass these in as command arguments
#---------------------------------------------------
ContainerID = 100777
IronBoxEmail = "[email protected]"
IronBoxPassword = "password"
IronBoxAPIServerURL = "https://api.goironcloud.com/latest/"
IronBoxAPIVersion = "latest"
# Gets all the blobs in the Ready state (2). Other states:
# 0 = Blob created
# 1 = Entity is uploading
# 2 = Ready
# 3 = Checked out
# 4 = Entity is modifying
# 5 = None
BlobState = 2
OutputDir = "./"
#---------------------------------------------------
# Main
#---------------------------------------------------
def main():
# Create an instance of the IronBox REST class
IronBoxRESTObj = IronBoxRESTClient(IronBoxEmail, IronBoxPassword, version=IronBoxAPIVersion, verbose=True)
# Get all the blobs in a ready state, result is a tuple list
# where 0 = blob ID and 1 = blob name
result = IronBoxRESTObj.GetContainerBlobInfoListByState(ContainerID, BlobState)
for item in result:
# Download and save the file locally
DestFilePath = join(OutputDir,item[1])
if IronBoxRESTObj.DownloadBlobFromContainer(ContainerID,item[0],DestFilePath) is True:
# Optionally you can delete the blob after download
#IronBoxRESTObj.RemoveEntityContainerBlob(ContainerID,item[0])
pass
#---------------------------------------------------
if __name__ == "__main__":
main()