File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from sys import exit
1313
1414PLUGIN_BASE = 'linode-cli image-upload'
15+ MAX_UPLOAD_SIZE = 5 * 1024 * 1024 * 1024 # 5GB
1516
1617
1718def _progress (cur , total ):
@@ -83,17 +84,22 @@ def call(args, context):
8384 # get default region populated
8485 context .client .config .update (parsed )
8586
86- if not parsed .region :
87- print ("No region provided. Please set a default region or use --region" )
88- exit (1 )
89-
9087 # make sure the file exists and is ready to upload
9188 filepath = os .path .expanduser (parsed .file )
9289
9390 if not os .path .isfile (filepath ):
9491 print ("No file at {}; must be a path to a valid file." .format (filepath ))
9592 exit (2 )
9693
94+ # make sure it's not larger than the max upload size
95+ if os .path .getsize (filepath ) > MAX_UPLOAD_SIZE :
96+ print ("File {} is too large; compressed size must be less than 5GB" .format (filepath ))
97+ exit (2 )
98+
99+ if not parsed .region :
100+ print ("No region provided. Please set a default region or use --region" )
101+ exit (1 )
102+
97103 label = parsed .label or os .path .basename (filepath )
98104
99105 # generate an upload URL
You can’t perform that action at this time.
0 commit comments