289
289
Reads fields: 'path', 'data' (file upload)
291
# TODO: Read field "unpack".
291
292
# Important: Data is "None" if the file submitted is empty.
292
293
path = fields.getfirst('path')
293
294
data = fields.getfirst('data')
306
307
raise ActionError("Could not write to target file")
309
def action_putfiles(req, fields):
310
"""Writes data to one or more files in a directory, overwriting them if
313
Reads fields: 'path', 'data' (file upload)
315
# TODO: Read field "unpack".
316
# Important: Data is "None" if the file submitted is empty.
317
path = fields.getfirst('path')
318
data = fields.getlist('data')
320
raise ActionError("Required field missing")
321
path = actionpath_to_local(req, path)
325
# Each of the uploaded files
326
filepath = os.path.join(path, datum.filename)
327
filedata = datum.file
329
# Copy the contents of file object 'data' to the path 'path'
331
dest = open(filepath, 'wb')
333
shutil.copyfileobj(filedata, dest)
339
raise ActionError("Could not write to target file")
342
"Could not write to one or more of the target files")
308
344
def action_copy_or_cut(req, fields, mode):
309
345
"""Marks specified files on the clipboard, stored in the
310
346
browser session. Sets clipboard for either a cut or copy operation