Skip to content
Snippets Groups Projects
Commit 1173e88b authored by Kevin S. Hahn's avatar Kevin S. Hahn
Browse files

Merge branch 'fix_attachments'

parents 716b40cf 901bb77d
No related branches found
No related tags found
No related merge requests found
......@@ -285,9 +285,13 @@ class Container(base.RequestHandler):
# first line is 'content-disposition' line, extract filename
# second line is content-type, determine how to write to a file, as bytes or as string
# third linedata_path = self.app.config['data_path'], just a separator, useless
if self.request.content_type != 'multipart/form-data':
self.abort(400, 'content-type must be "multipart/form-data"')
# TODO: metadata validation
_id = bson.ObjectId(cid)
container, _ = self._get(_id, 'rw')
data_path = self.app.config['data_path']
quarantine_path = self.app.config['quarantine_path']
_id = bson.ObjectId(cid)
hashes = []
with tempfile.TemporaryDirectory(prefix='.tmp', dir=self.app.config['data_path']) as tempdir_path:
# get and hash the metadata
......
......@@ -50,14 +50,16 @@ def insert_file(dbc, _id, file_info, filepath, digest, data_path, quarantine_pat
)
filename = dataset.nims_file_name + dataset.nims_file_ext
else:
file_spec = dict(
_id=_id,
flavor={'$elemMatch': {
file_spec = {
'_id': _id,
flavor: {'$elemMatch': {
'type': file_info.get('type'),
'kinds': file_info.get('kinds'),
'state': file_info.get('state'),
}},
)
}
if flavor == 'attachments':
file_spec[flavor]['$elemMatch'].update({'name': file_info.get('name'), 'ext': file_info.get('ext')})
container_path = os.path.join(data_path, str(_id)[-3:] + '/' + str(_id))
if not os.path.exists(container_path):
os.makedirs(container_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment