Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bulk2 upload and download utf-8 encoding errors. #688

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'pytest',
'pytz>=2014.1.1',
'responses>=0.5.1',
'cryptography<3.4',
'cryptography>4.0.0',
],
test_suite='simple_salesforce.tests',
keywords=about['__keywords__'],
Expand Down
6 changes: 3 additions & 3 deletions simple_salesforce/bulk2.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class _Bulk2Client:
"""Bulk 2.0 API client"""

JSON_CONTENT_TYPE = "application/json"
CSV_CONTENT_TYPE = "text/csv"
CSV_CONTENT_TYPE = "text/csv; charset=UTF-8"

DEFAULT_WAIT_TIMEOUT_SECONDS = 86400 # 24-hour bulk job running time
MAX_CHECK_INTERVAL_SECONDS = 2.0
Expand Down Expand Up @@ -429,7 +429,7 @@ def get_query_results(
return {
"locator": locator,
"number_of_records": number_of_records,
"records": self.filter_null_bytes(result.text),
"records": self.filter_null_bytes(result.content.decode('utf-8')),
}

def download_job_data(
Expand Down Expand Up @@ -508,7 +508,7 @@ def upload_job_data(self, job_id, data: str, content_url=None):
method="PUT",
session=self.session,
headers=headers,
data=data,
data=data.encode("utf-8"),
)
if result.status_code != http.CREATED:
raise SalesforceBulkV2LoadError(
Expand Down