def dropbox_upload(pub_id=None, fileurl=''): """ Dropbox upload backend """ if pub_id: pub_id = pub_id.encode('utf8') if fileurl: fileurl = fileurl.encode('utf8') uid = current_user.get_id() if not fileurl: abort(400) if not (fileurl.startswith("https://dl.dropbox.com/") or fileurl.startswith("https://dl.dropboxusercontent.com/")): abort(400) publication = OpenAIREPublication(uid) if not is_editable(publication): flash("You cannot upload new files when your upload has already been submitted!") abort(400) # Pre-fill user collection c = request.values.get('c', None) if c: publication.add_usercollection(c) uploaded_file = download_external_url(fileurl) publication.add_a_fulltext(uploaded_file, secure_filename(os.path.basename(fileurl))) return redirect(url_for('deposit.edit', pub_id=publication.publicationid))
def dropbox_upload(pub_id=None, fileurl=''): """ Dropbox upload backend """ if pub_id: pub_id = pub_id.encode('utf8') if fileurl: fileurl = fileurl.encode('utf8') uid = current_user.get_id() if not fileurl: abort(400) if not (fileurl.startswith("https://dl.dropbox.com/") or fileurl.startswith("https://dl.dropboxusercontent.com/")): abort(400) publication = OpenAIREPublication(uid) if not is_editable(publication): flash( "You cannot upload new files when your upload has already been submitted!" ) abort(400) # Pre-fill user collection c = request.values.get('c', None) if c: publication.add_usercollection(c) uploaded_file = download_external_url(fileurl) publication.add_a_fulltext(uploaded_file, secure_filename(os.path.basename(fileurl))) return redirect(url_for('deposit.edit', pub_id=publication.publicationid))
def upload(pub_id=None): """ PLUpload backend """ if pub_id: pub_id = pub_id.encode('utf8') uid = current_user.get_id() if 'file' not in request.files: abort(400) afile = request.files['file'] filename = secure_filename(afile.filename) publication = OpenAIREPublication(uid, publicationid=pub_id) # Pre-fill user collection: c = request.values.get('c', None) if c: publication.add_usercollection(c) if not is_editable(publication): flash("You cannot upload new files when your upload has already been submitted!") abort(400) publication.add_a_fulltext(None, filename, req_file=afile) return publication.publicationid
def upload(pub_id=None): """ PLUpload backend """ if pub_id: pub_id = pub_id.encode('utf8') uid = current_user.get_id() if 'file' not in request.files: abort(400) afile = request.files['file'] filename = secure_filename(afile.filename) publication = OpenAIREPublication(uid, publicationid=pub_id) # Pre-fill user collection: c = request.values.get('c', None) if c: publication.add_usercollection(c) if not is_editable(publication): flash( "You cannot upload new files when your upload has already been submitted!" ) abort(400) publication.add_a_fulltext(None, filename, req_file=afile) return publication.publicationid