8000 added allowed file extensions to workbooks_endpoint (#20) · subodhgupta/server-client-python@9789f46 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 9789f46

Browse files
authored
added allowed file extensions to workbooks_endpoint (tableau#20)
1 parent 0245d6a commit 9789f46

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tableauserverapi/server/endpoint/workbooks_endpoint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# The maximum size of a file that can be published in a single request is 64MB
1212
FILESIZE_LIMIT = 1024 * 1024 * 64 # 64MB
1313

14+
ALLOWED_FILE_EXTENSIONS = ['twb', 'twbx']
15+
1416
logger = logging.getLogger('tableau.endpoint.workbooks')
1517

1618

@@ -152,8 +154,8 @@ def publish(self, workbook_item, file_path, mode):
152154
# If name is not defined, grab the name from the file to publish
153155
if not workbook_item.name:
154156
workbook_item.name = os.path.splitext(filename)[0]
155-
if file_extension != 'twb' and file_extension != 'twbx':
156-
error = "Only .twb and .twbx files can be published as workbooks."
157+
if file_extension not in ALLOWED_FILE_EXTENSIONS:
158+
error = "Only {} files can be published as workbooks.".format(', '.join(ALLOWED_FILE_EXTENSIONS))
157159
raise ValueError(error)
158160

159161
# Construct the url with the defined mode

0 commit comments

Comments
 (0)
0