tableau_tools icon indicating copy to clipboard operation
tableau_tools copied to clipboard

Unable to upload files larger than 20mb

Open kabelak opened this issue 6 years ago • 6 comments

Publish call fails for extracts larger than 20mb.

The error occurs when tableau_rest_api_connection.py runs append_to_file_upload, specifically the publish += content. The error is TypeError: must be str, not bytes.

I dug in and can change the single_upload_limit to 64, but that doesn't solve the problem for extracts larger than this.

I've seen similar issues reported for workbooks, but I guess they both use the same functions.

kabelak avatar Mar 26 '19 14:03 kabelak

Actually Fixed this by modifying the function to become inline with code above it:

    def append_to_file_upload(self, upload_session_id, content, filename):
        boundary_string = self.generate_boundary_string()
        publish_request = bytes("--{}\r\n".format(boundary_string).encode('utf-8'))
        publish_request += bytes('Content-Disposition: name="request_payload"\r\n'.encode('utf-8'))
        publish_request += bytes('Content-Type: text/xml\r\n\r\n'.encode('utf-8'))
        publish_request += bytes('\r\n'.encode('utf-8'))
        publish_request += bytes("--{}\r\n".format(boundary_string).encode('utf-8'))

        publish_request += bytes('Content-Disposition: name="tableau_file"; filename="{}"\r\n'.format(
            filename).encode('utf-8'))
        publish_request += bytes('Content-Type: application/octet-stream\r\n\r\n'.encode('utf-8'))

        publish_request += content

        publish_request += bytes("\r\n--{}--".format(boundary_string).encode('utf-8'))
        url = self.build_api_url("fileUploads/{}".format(upload_session_id))
        self.send_append_request(url, publish_request, boundary_string)

kabelak avatar Mar 26 '19 15:03 kabelak

I'm encountering the same issue. However when I try to apply your fix, I am getting the original error message but for the line: publish_request += bytes('Content-Disposition: name="tableau_file"; filename="{}"\r\n'.format( filename).encode('utf-8'))

Do you have any recommendations?

JasonPolsky avatar Jul 25 '19 15:07 JasonPolsky

I'm not sure - can you paste in here the whole of the error message?

kabelak avatar Jul 26 '19 07:07 kabelak

Can anyone confirm if they are still seeing this issue with latest versions. I just released a 5.X version that is rewritten specifically for Python 3.6 and hopefully doesn't encounter any of the encoding issues that arose from the automatic translation like before

bryanthowell-tableau avatar Dec 08 '19 17:12 bryanthowell-tableau

I had this issue with Python 3.7.6. Solution above by @kabelak fixed it for me. I'm a Python amateur, so not sure best information to provide, but if you tell me what's useful, I'll get it for you. Btw thanks for this v useful package.

philbroberts avatar Apr 02 '20 13:04 philbroberts

I've also had this issue today, the fix above from @kabelak has also worked for me. Please merge into master branch :)

SafriDane avatar May 20 '21 02:05 SafriDane