-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathIronBoxUploadFileCmdLine.py
60 lines (54 loc) · 1.94 KB
/
IronBoxUploadFileCmdLine.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 upload a file to
# an IronBox secure package or container
# using command line parameters:
#
# Usage:
# IronBoxUploadFileCmdLine.py containerid email password file_to_upload
#
# Written by [email protected]
# Website: www.goironbox.com
#
#---------------------------------------------------
from IronBoxREST import IronBoxRESTClient
import sys, os
from os import path
#---------------------------------------------------
# Your IronBox authentication parameters, these will
# be set by command line arguments
#---------------------------------------------------
ContainerID = 0
IronBoxEmail = ""
IronBoxPassword = ""
IronBoxAPIServerURL = "https://api.goironcloud.com/latest/"
IronBoxAPIVersion = "latest"
InFile = ""
IronBoxFileName = ""
#---------------------------------------------------
# Main
#---------------------------------------------------
def main():
#-----------------------------------------------
# Parse command line arguments
#-----------------------------------------------
ContainerID = sys.argv[1]
IronBoxEmail = sys.argv[2]
IronBoxPassword = sys.argv[3]
InFile = sys.argv[4]
IronBoxFileName = path.basename(InFile)
#-----------------------------------------------
# Create an instance of the IronBox REST class
#-----------------------------------------------
IronBoxRESTObj = IronBoxRESTClient(IronBoxEmail, IronBoxPassword, version=IronBoxAPIVersion, verbose=True)
#-----------------------------------------------
# Upload the file to IronBox
# Duplicate file names will automatically
# get renamed
#-----------------------------------------------
IronBoxRESTObj.UploadFileToContainer(ContainerID, InFile, IronBoxFileName)
#---------------------------------------------------
import string, datetime
if __name__ == "__main__":
main()