Ejemplo n.º 1
0
def uploadAction(req_info):
    LOG.debug("[uploadAction] Upload action called.")
    to_save = [f for f in req_info.fields.list if f.name == 'u' and len(f.filename.strip()) > 0]
    LOG.debug("Uploading: %s" % to_save)
    err = io.saveFiles(to_save, req_info.fs_path)
    if err: 
        req_info.add_error(err)

    return defaultAction(req_info)
Ejemplo n.º 2
0
def uploadFilesAction(user, fields, root, admin_context, gallery_context):
    errors = []
    action = fields.getfirst("action")
    
    if action and action == 'delete_folder':
        field = fields.getfirst("folder")
        if field:
            err = io.tryDeleteFolder(root, field)
            if err:
                errors.append(err)
    elif fields.getfirst('upload'):
        localroot = path.join(root, fields.getfirst('folder', user))
        to_save = [f for f in fields.list if f.name == 'u' and len(f.filename.strip()) > 0]
        err = io.saveFiles(to_save, localroot)
        if err: 
            errors.append(err)
    
    content_type = "text/html"
    data = io.getUploadPage(user, io.getFolders(user, root), errors, None, admin_context, gallery_context)
    response = apache.OK
    
    return data, content_type, response