Skip to content

Commit

Permalink
use urlparse to generate url safe file names (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
parthshahva committed Apr 11, 2019
1 parent e38364b commit 9d910a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hca/upload/api_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import json
try:
import urllib.parse as urlparse
except ImportError:
import urllib as urlparse

This comment has been minimized.

Copy link
@kislyuk

kislyuk Apr 16, 2019

Member

Please use https://github.com/HumanCellAtlas/dcp-cli/blob/master/hca/util/compat.py for this type of conditional importing.

This comment has been minimized.

Copy link
@sampierson

sampierson Apr 16, 2019

Member

import requests
from tenacity import retry, stop_after_attempt, wait_fixed
Expand Down Expand Up @@ -35,9 +39,10 @@ def credentials(self, area_uuid):

@retry(reraise=True, wait=wait_fixed(2), stop=stop_after_attempt(3))
def file_upload_notification(self, area_uuid, filename):
url_safe_filename = urlparse.quote(filename)
url = "{api_url_base}/area/{area_uuid}/{filename}".format(api_url_base=self.api_url_base,
area_uuid=area_uuid,
filename=filename)
filename=url_safe_filename)
response = requests.post(url)
if not response.status_code == requests.codes.accepted:
raise RuntimeError(
Expand Down

0 comments on commit 9d910a3

Please sign in to comment.