Skip to content

Commit

Permalink
Add extra data option to add_source
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimadraz committed May 23, 2024
1 parent d6cb380 commit 2f60065
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pycrunch/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import six

from pycrunch import shoji, csvlib
from pycrunch import csvlib, shoji


class Importer(object):
Expand Down Expand Up @@ -53,13 +53,13 @@ def wait_for_batch_status(self, batch, status):
raise ValueError("The batch did not reach the '%s' state in the "
"given time. Please check again later." % status)

def add_source(self, ds, filename, fp, mimetype):
def add_source(self, ds, filename, fp, mimetype, data={}):
"""Create a new Source on the given dataset and return its URL."""
sources_url = ds.user_url.catalogs['sources']
# Don't call Catalog.post here (which would force application/json);
# we want requests.Session to set multipart/form-data with a boundary.
new_source_url = ds.session.post(
sources_url, files={"uploaded_file": (filename, fp, mimetype)}
sources_url, files={"uploaded_file": (filename, fp, mimetype)}, data=data
).headers["Location"]

if self.strict is not None:
Expand Down

0 comments on commit 2f60065

Please sign in to comment.