예제 #1
0
def upload_url():
    """Upload a distant file with an URL

    Returns
    -------
    json
        error: True if error, else False
        errorMessage: the error message of error, else an empty string
    """
    files_utils = FilesUtils(current_app, session)
    disk_space = files_utils.get_size_occupied_by_user() if "user" in session else None

    if session["user"]["quota"] > 0 and disk_space >= session["user"]["quota"]:
        return jsonify({
            'errorMessage': "Exceeded quota",
            "error": True
        }), 500

    data = request.get_json()

    try:
        files = FilesHandler(current_app, session)
        files.download_url(data["url"])
    except Exception as e:
        traceback.print_exc(file=sys.stdout)
        return jsonify({
            "error": True,
            "errorMessage": str(e)
        }), 500
    return jsonify({
        "error": False,
        "errorMessage": ""
    })
예제 #2
0
def download_file(self, session, url):
    """Send a mail to the new user

    Parameters
    ----------
    session : dict
        AskOmics session
    user : dict
        New user
    """
    files = FilesHandler(app, session)
    files.download_url(url, download_file.request.id)
예제 #3
0
    def upload_file_url(self, file_url):
        """Summary

        Parameters
        ----------
        file_path : TYPE
            Description

        Returns
        -------
        TYPE
            Description
        """

        files = FilesHandler(self.app, self.session)
        files.download_url(file_url, "1")
        return files.date