You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to return bytes stream to workbooks.download() method #811
It would be nice if workbooks.download() method could also return bytes stream for downloaded object. For example, add argument stream=True/False to download function that would define whether object should be downloaded into specified path or returned as a byte stream. https://github.com/tableau/server-client-python/blob/master/tableauserverclient/server/endpoint/workbooks_endpoint.py#L134
In this case byte stream can be handled outside of library, for example it can be used to write data in AWS S3 bucket, GCS bucket or Azure Blob storage instead of local storage.
Example:
def download(self, workbook_id, filepath=None, include_extract=True, no_extract=None, stream=False):
if not workbook_id:
error = "Workbook ID undefined."
raise ValueError(error)
url = "{0}/{1}/content".format(self.baseurl, workbook_id)
if no_extract is False or no_extract is True:
import warnings
warnings.warn('no_extract is deprecated, use include_extract instead.', DeprecationWarning)
include_extract = not no_extract
if not include_extract:
url += "?includeExtract=False"
with closing(self.get_request(url, parameters={"stream": True})) as server_response:
_, params = cgi.parse_header(server_response.headers['Content-Disposition'])
filename = to_filename(os.path.basename(params['filename']))
if filepath:
download_path = make_download_path(filepath, filename)
with open(download_path, 'wb') as f:
for chunk in server_response.iter_content(1024): # 1KB
f.write(chunk)
logger.info('Downloaded workbook to {0} (ID: {1})'.format(download_path, workbook_id))
return os.path.abspath(download_path)
if stream:
return server_response.content
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this is still relevant, please comment to keep it open.
Activity
SandervandenOord commentedon May 22, 2022
Agree, now I first have to write to disk and then write to a cloud storage bucket
github-actions commentedon Aug 6, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this is still relevant, please comment to keep it open.
github-actions commentedon Aug 21, 2026
Closing due to inactivity. If this is still relevant, please reopen or file a new issue.
jacalata commentedon Aug 21, 2026
workbooks.download()anddownload_revision()accept a file-like object asfilepath. Passio.BytesIO()and the bytes stream is populated in place.