コード例 #1
0
def sample16(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    fileId = request.POST.get('fileId')
    guid = None
    iframe = None
    # Checking required parameters
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample16.pt',
                                  dict(error='You do not enter all parameters'))

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage object
    api = StorageApi(apiClient)
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    if url:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = None
        except Exception, e:
            return render_to_response('__main__:templates/sample16.pt',
                                      dict(error=str(e)))
コード例 #2
0
def sample27(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    fileId = request.POST.get('fileId')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    name = request.POST.get('name')
    sex = request.POST.get('sex')
    age = request.POST.get('age')
    sunrise = request.POST.get('sunrise')
    type = request.POST.get('type')
    fileGuId = None
    # Checking clientId and privateKey
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample27.pt',
                                  dict(error='You do not enter your User Id or Private Key'))
        ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storage = StorageApi(apiClient)
    #Create AsyncApi object
    async = AsyncApi(apiClient)
    #Create MergeApi object
    merge = MergeApi(apiClient)
    #Create DocApi object
    doc = DocApi(apiClient)
    #Check is base path entered
    if not basePath:
        #If base path empty set base path to the dev server
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path for api
    storage.basePath = basePath
    async.basePath = basePath
    merge.basePath = basePath
    doc.basePath = basePath
    #If user choose local file upload
    if inputFile.filename:

        #A hack to get uploaded file size
        inputFile.file.seek(0, 2)
        fileSize = inputFile.file.tell()
        inputFile.file.seek(0)

        fs = FileStream.fromStream(inputFile.file, fileSize)
        ####Make a request to Storage API using clientId
        try:

            #Upload file to current user storage
            upload = storage.Upload(clientId, inputFile.filename,  fs, overrideMode=0)
            if upload.status == "Ok":
                #Get file guid
                fileGuId = upload.result.guid
        except Exception, e:
            return render_to_response('__main__:templates/sample27.pt',
                                      dict(error=str(e)))
コード例 #3
0
def sample17(request):

    clientId = request.POST.get("clientId")
    privateKey = request.POST.get("privateKey")
    inputFile = request.POST.get("file")
    url = request.POST.get("url")
    basePath = request.POST.get("basePath")
    resultId = None
    # Checking required parameters
    if not clientId or not privateKey:
        return render_to_response("__main__:templates/sample17.pt", dict(error="You do not enter all parameters"))

    ### Create Signer, ApiClient and StorageApi objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create StorageApi object
    api = StorageApi(apiClient)
    if not basePath:
        basePath = "https://api.groupdocs.com/v2.0"
    # Set base path
    api.basePath = basePath
    if url:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = api.UploadWeb(clientId, url)
            resultId = upload.result.id
            inputFile = None
        except Exception, e:
            return render_to_response("__main__:templates/sample17.pt", dict(error=str(e)))
コード例 #4
0
def sample16(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileId = request.POST.get('fileId')
    guid = ""
    iframe = ""
    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample16.pt',
                                  {'error': 'You do not enter all parameters'})

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage object
    api = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response('__main__:templates/sample16.pt',
                                      {'error': str(e)})
コード例 #5
0
def sample16(request):
    clientId = request.POST.get("client_id")
    privateKey = request.POST.get("private_key")
    inputFile = request.POST.get("file")
    url = request.POST.get("url")
    basePath = request.POST.get("server_type")
    fileId = request.POST.get("fileId")
    guid = ""
    iframe = ""
    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response("__main__:templates/sample16.pt", {"error": "You do not enter all parameters"})

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage object
    api = StorageApi(apiClient)
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
        # Set base path
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response("__main__:templates/sample16.pt", {"error": str(e)})
コード例 #6
0
def sample05(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileId = request.POST.get('srcPath')
    ID = ""
    name = ''
    message = ''
    destPath = request.POST.get('destPath')
    copy = request.POST.get('copy')
    move = request.POST.get('move')

    ####Check clientId, privateKey and file Id
    if IsNotNull(clientId) == False or IsNotNull(
            privateKey) == False or IsNotNull(destPath) == False:
        return render_to_response('__main__:templates/sample05.pt',
                                  {'error': 'You do not enter all parameters'})

    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    api = StorageApi(apiClient)
    #Check base path
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            ID = upload.result.id

            try:
                ####Make a request to Storage API using clientId

                #Obtaining all Entities from current user
                files = api.ListEntities(userId=clientId,
                                         path='My Web Documents',
                                         pageIndex=0)
                #Obtaining file name
                for item in files.result.files:
                    #selecting file names
                    if item.guid == upload.result.guid:
                        name = item.name

            except Exception, e:
                return render_to_response('__main__:templates/sample05.pt',
                                          {'error': str(e)})
        except Exception, e:
            return render_to_response('__main__:templates/sample05.pt',
                                      {'error': str(e)})
コード例 #7
0
def sample35(request):
    ####Check which form is now field. If not "guid" that first form.
    if request.POST.get('guid') == None or request.POST.get('guid') == '':
        #Get posted data
        clientId = request.POST.get('clientId')
        privateKey = request.POST.get('privateKey')
        inputFile = request.POST.get('file')
        fileId = request.POST.get('guidField')
        url = request.POST.get('url')
        basePath = request.POST.get('basePath')
        # Checking clientId and privateKey
        if not clientId or not privateKey:
            return render_to_response('__main__:templates/sample35.pt',
                dict(error='You do not enter your User Id or Private Key', newForm=""))
        #Create signer object
        signer = GroupDocsRequestSigner(privateKey)
        #Create apiClient object
        apiClient = ApiClient(signer)
        #Create Storage Api object
        storage = StorageApi(apiClient)
        #Create DocApi object
        doc = DocApi(apiClient)
        #Check is base path entered
        if not basePath:
            #If base path empty set base path to the dev server
            basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path for api
        storage.basePath = basePath
        doc.basePath = basePath
        #If user choose local file upload
        if inputFile.filename:
            #A hack to get uploaded file size
            inputFile.file.seek(0, 2)
            fileSize = inputFile.file.tell()
            inputFile.file.seek(0)
            fs = FileStream.fromStream(inputFile.file, fileSize)
            ####Make a request to Storage API using clientId
            try:
                #Upload file to current user storage
                upload = storage.Upload(clientId, inputFile.filename,  fs, overrideMode=0)
                if upload.status == "Ok":
                    #Get file guid
                    fileGuId = upload.result.guid
            except Exception, e:
                return render_to_response('__main__:templates/sample35.pt',
                    dict(error=str(e), newForm= ''))
        #If user choose upload file from web
        if url:
            try:
                # Upload file to current user storage using entered URl to the file
                uploadWeb = storage.UploadWeb(clientId, url)
                # Check if file uploaded successfully
                if uploadWeb.status == "Ok":
                    #Get file guid
                    fileGuId = uploadWeb.result.guid
            except Exception, e:
                return render_to_response('__main__:templates/sample35.pt',
                    dict(error=str(e), newForm= ''))
コード例 #8
0
def sample05(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    fileId = request.POST.get('srcPath')
    name = None
    message = None
    path = None
    destPath = request.POST.get('destPath')
    copy = request.POST.get('copy')
    move = request.POST.get('move')
    if destPath:
        if destPath.find("/") != -1:
            destPath = destPath
        elif destPath.find("\\") != -1 or destPath.find("/") == -1:
            destPath = destPath.replace("\\", "")
            destPath = destPath + "/"
    else:
        destPath = ''
    ####Check clientId, privateKey and file Id
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample05.pt',
                                  {'error': 'You do not enter all parameters'})

    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storageApi = StorageApi(apiClient)
    docApi = DocApi(apiClient)
    #Check base path
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    storageApi.basePath = basePath
    if url:

        try:
            # Upload file to current user storage using entered URl to the file
            upload = storageApi.UploadWeb(clientId, url)
            ID = upload.result.id
            ####Make a request to Storage API using clientId

            #Obtaining all Entities from current user
            files = storageApi.ListEntities(userId=clientId, path='My Web Documents', pageIndex=0)
            #Obtaining file name
            for item in files.result.files:
                #selecting file names
                if item.guid == upload.result.guid:
                    name = item.name
        except Exception, e:
            return render_to_response('__main__:templates/sample05.pt',
                                      {'error': str(e)})
コード例 #9
0
def sample25(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    fileId = request.POST.get('fileId')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileGuId = ""

    # Checking clientId and privateKey
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response(
            '__main__:templates/sample25.pt',
            {'error': 'You do not enter your User Id or Private Key'})
####Create Signer, ApiClient and Storage Api objects

#Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storage = StorageApi(apiClient)
    #Create AsyncApi object
    async = AsyncApi(apiClient)
    #Create MergeApi object
    merg = MergeApi(apiClient)
    #Create DocApi object
    doc = DocApi(apiClient)
    #Check is base path entered
    if basePath == "":
        #If base path empty set base path to the dev server
        basePath = 'https://api.groupdocs.com/v2.0'
#Set base path for api
    storage.basePath = basePath
    async .basePath = basePath
    merg.basePath = basePath
    doc.basePath = basePath
    #If user choose local file upload
    if inputFile.filename != "":

        #A hack to get uploaded file size
        inputFile.file.seek(0, 2)
        fileSize = inputFile.file.tell()
        inputFile.file.seek(0)

        fs = FileStream.fromStream(inputFile.file, fileSize)
        ####Make a request to Storage API using clientId
        try:

            #Upload file to current user storage
            upload = storage.Upload(clientId, inputFile.filename, fs)
            if upload.status == "Ok":
                #Get file guid
                fileGuId = upload.result.guid
        except Exception, e:
            return render_to_response('__main__:templates/sample25.pt',
                                      {'error': str(e)})
コード例 #10
0
def sample25(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    fileId = request.POST.get('fileId')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileGuId = ""

    # Checking clientId and privateKey
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample25.pt',
                                  { 'error' : 'You do not enter your User Id or Private Key' })
####Create Signer, ApiClient and Storage Api objects

#Create signer object
    signer = GroupDocsRequestSigner(privateKey)
#Create apiClient object
    apiClient = ApiClient(signer)
#Create Storage Api object
    storage = StorageApi(apiClient)
#Create AsyncApi object
    async = AsyncApi(apiClient)
#Create MergeApi object
    merg = MergeApi(apiClient)
#Create DocApi object
    doc = DocApi(apiClient)
#Check is base path entered
    if basePath == "":
        #If base path empty set base path to the dev server
        basePath = 'https://api.groupdocs.com/v2.0'
#Set base path for api
    storage.basePath = basePath
    async.basePath = basePath
    merg.basePath = basePath
    doc.basePath = basePath
#If user choose local file upload
    if inputFile.filename != "":

            #A hack to get uploaded file size
            inputFile.file.seek(0, 2)
            fileSize = inputFile.file.tell()
            inputFile.file.seek(0)

            fs = FileStream.fromStream(inputFile.file, fileSize)
            ####Make a request to Storage API using clientId
            try:

                #Upload file to current user storage
                upload = storage.Upload(clientId, inputFile.filename, fs)
                if upload.status == "Ok":
                    #Get file guid
                    fileGuId = upload.result.guid
            except Exception, e:
                return render_to_response('__main__:templates/sample25.pt',
                                          { 'error' : str(e) })
コード例 #11
0
def sample03(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    folderPath = request.POST.get('folderPath')
    basePath = request.POST.get('basePath')
    guid = None
    name = None
    if folderPath:
        if folderPath.find("/") != -1:
            folderPath = folderPath
        elif folderPath.find("\\") != -1 or folderPath.find("/") == -1:
            folderPath = folderPath.replace("\\", "")
            folderPath = folderPath + "/"
    # Checking clientId and privateKey
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample03.pt',
                                  dict(error='You do not enter your User Id or Private Key'))
    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    api = StorageApi(apiClient)
    #Check base path
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    if url:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            try:
                ####Make a request to Storage API using clientId

                #Obtaining all Entities from current user
                files = api.ListEntities(userId=clientId, path='My Web Documents', pageIndex=0)
                #Obtaining file name
                for item in files.result.files:
                    #selecting file names
                    if item.guid == guid:
                        name = item.name

            except Exception, e:
                return render_to_response('__main__:templates/sample03.pt',
                                          {'error': str(e)})

        except Exception, e:
            return render_to_response('__main__:templates/sample03.pt',
                                      {'error': str(e)})
コード例 #12
0
def sample44(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    basePath = request.POST.get('basePath')
    firstName = request.POST.get('firstName')
    gender = request.POST.get('gender')
    lastName = request.POST.get('lastName')
    firstEmail = request.POST.get('firstEmail')
    secondEmail = request.POST.get('secondEmail')
    fileGuId = None
    # Checking clientId and privateKey
    if not clientId or not privateKey or not firstEmail or not firstName or not secondEmail:
        return render_to_response('__main__:templates/sample44.pt',
                                  dict(error='Please enter all required data', url1=''))
    ####Create Signer, ApiClient and Storage Api objects
    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storage = StorageApi(apiClient)
    #Create AsyncApi object
    async = AsyncApi(apiClient)
    #Create MergeApi object
    merge = MergeApi(apiClient)
    #Create DocApi object
    doc = DocApi(apiClient)
    #Create Signature object
    signature = SignatureApi(apiClient)
    #Check is base path entered
    if not basePath:
        #If base path empty set base path to the dev server
        basePath = 'https://api.groupdocs.com/v2.0'
    #Set base path for api
    storage.basePath = basePath
    async.basePath = basePath
    merge.basePath = basePath
    doc.basePath = basePath
    signature.basePath = basePath
    #A hack to get uploaded file size
    inputFile.file.seek(0, 2)
    fileSize = inputFile.file.tell()
    inputFile.file.seek(0)
    fs = FileStream.fromStream(inputFile.file, fileSize)
    ####Make a request to Storage API using clientId
    try:
        #Upload file to current user storage
        upload = storage.Upload(clientId, inputFile.filename,  fs, overrideMode=0)
        if upload.status == "Ok":
            #Get file guid
            fileGuId = upload.result.guid
    except Exception, e:
        return render_to_response('__main__:templates/sample44.pt',
                                  dict(error=str(e), url1=''))
コード例 #13
0
def sample05(request):
    clientId = request.POST.get("client_id")
    privateKey = request.POST.get("private_key")
    inputFile = request.POST.get("file")
    url = request.POST.get("url")
    basePath = request.POST.get("server_type")
    fileId = request.POST.get("srcPath")
    ID = ""
    name = ""
    message = ""
    destPath = request.POST.get("destPath")
    copy = request.POST.get("copy")
    move = request.POST.get("move")

    ####Check clientId, privateKey and file Id
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(destPath) == False:
        return render_to_response("__main__:templates/sample05.pt", {"error": "You do not enter all parameters"})

    ####Create Signer, ApiClient and Storage Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage Api object
    api = StorageApi(apiClient)
    # Check base path
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
        # Set base path
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            ID = upload.result.id

            try:
                ####Make a request to Storage API using clientId

                # Obtaining all Entities from current user
                files = api.ListEntities(userId=clientId, path="My Web Documents", pageIndex=0)
                # Obtaining file name
                for item in files.result.files:
                    # selecting file names
                    if item.guid == upload.result.guid:
                        name = item.name

            except Exception, e:
                return render_to_response("__main__:templates/sample05.pt", {"error": str(e)})
        except Exception, e:
            return render_to_response("__main__:templates/sample05.pt", {"error": str(e)})
コード例 #14
0
def sample03(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    guid = ""
    name = ""
    # Checking clientId and privateKey
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample03.pt',
                                  { 'error' : 'You do not enter your User Id or Private Key' })
####Create Signer, ApiClient and Storage Api objects

#Create signer object
    signer = GroupDocsRequestSigner(privateKey)
#Create apiClient object
    apiClient = ApiClient(signer)
#Create Storage Api object
    api = StorageApi(apiClient)
    #Check base path
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
    #Set base path
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            try:
                ####Make a request to Storage API using clientId

                #Obtaining all Entities from current user
                files = api.ListEntities(userId = clientId, path = 'My Web Documents', pageIndex = 0)
                #Obtaining file name
                for item in files.result.files:
                    #selecting file names
                    if item.guid == guid:
                        name = item.name

            except Exception, e:
                return render_to_response('__main__:templates/sample03.pt',
                    { 'error' : str(e) })

        except Exception, e:
            return render_to_response('__main__:templates/sample03.pt',
                { 'error' : str(e) })
コード例 #15
0
def sample24(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    iframe = None
    # Checking required parameters
    if not clientId or not privateKey or not url:
        return render_to_response('__main__:templates/sample24.pt',
                                  dict(error='You do not enter all parameters'))

    ### Create Signer, ApiClient and Storage Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage Api object
    storage = StorageApi(apiClient)
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
    storage.basePath = basePath
    # Upload file to current user storage using entered URl to the file
    upload = storage.UploadWeb(clientId, url)
    # Check if file uploaded successfully
    if upload.status == "Ok":
        # Generation of Embedded Viewer URL with uploaded file GuId
    # Generation of iframe URL using pageImage.result.guid
        if basePath == "https://api.groupdocs.com/v2.0":
            iframe = 'https://apps.groupdocs.com/document-viewer/embed/' + upload.result.guid
        elif basePath == "https://dev-api.groupdocs.com/v2.0":
            iframe = 'https://dev-apps.groupdocs.com/document-viewer/embed/' + upload.result.guid
        elif basePath == "https://stage-api.groupdocs.com/v2.0":
            iframe = 'https://stage-apps.groupdocs.com/document-viewer/embed/' + upload.result.guid
        iframe = signer.signUrl(iframe)


    # If request was successful - set variables for template
    return render_to_response('__main__:templates/sample24.pt',
        {
            'userId' : clientId,
            'privateKey' : privateKey,
            'url' : url,
            'iframe' : iframe,
        },
        request=request)
コード例 #16
0
def sample33(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    firstUrl = request.POST.get('url1')
    secondUrl = request.POST.get('url2')
    thirdUrl = request.POST.get('url3')
    basePath = request.POST.get('server_type')
    message = ""
    iframe = ""
    # Checking clientId, privateKey and file_Id
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample33.pt',
                                  {'error': 'You do not enter all parameters'})

    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storageApi = StorageApi(apiClient)
    #Create Async api object
    asyncApi = AsyncApi(apiClient)
    #Set base Path
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
    storageApi.basePath = basePath
    asyncApi.basePath = basePath
    #Create list of URL's
    urlList = [firstUrl, secondUrl, thirdUrl]
    #Create empty list for uploaded files GUID's
    guidList = []
    for url in urlList:
        try:
            #Upload file
            upload = storageApi.UploadWeb(clientId, url)
            if upload.status == "Ok":
                #Add GUID of uploaded file to list
                guidList.append(upload.result.guid)
            else:
                raise Exception(upload.error_message)
        except Exception, e:
            return render_to_response('__main__:templates/sample33.pt',
                                      {'error': str(e)})
コード例 #17
0
def sample33(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    firstUrl = request.POST.get('url1')
    secondUrl = request.POST.get('url2')
    thirdUrl = request.POST.get('url3')
    basePath = request.POST.get('server_type')
    message = ""
    iframe = ""
    # Checking clientId, privateKey and file_Id
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample33.pt',
                                  { 'error' : 'You do not enter all parameters' })

    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storageApi = StorageApi(apiClient)
    #Create Async api object
    asyncApi = AsyncApi(apiClient)
    #Set base Path
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
    storageApi.basePath = basePath
    asyncApi.basePath = basePath
    #Create list of URL's
    urlList = [firstUrl, secondUrl, thirdUrl]
    #Create empty list for uploaded files GUID's
    guidList = []
    for url in urlList:
        try:
            #Upload file
            upload = storageApi.UploadWeb(clientId, url)
            if upload.status == "Ok":
                #Add GUID of uploaded file to list
                guidList.append(upload.result.guid)
            else:
                raise Exception(upload.error_message)
        except Exception, e:
            return render_to_response('__main__:templates/sample33.pt',
                { 'error' : str(e) })
コード例 #18
0
def sample24(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(
            privateKey) == False or IsNotNull(url) == False:
        return render_to_response('__main__:templates/sample24.pt',
                                  {'error': 'You do not enter all parameters'})

    ### Create Signer, ApiClient and Storage Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage Api object
    storage = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
    storage.basePath = basePath
    # Upload file to current user storage using entere URl to the file
    upload = storage.UploadWeb(clientId, url)
    # Check if file uploaded successfully
    if upload.status == "Ok":
        # Generation of Embeded Viewer URL with uploaded file GuId
        # Generation of iframe URL using pageImage.result.guid
        if basePath == "https://api.groupdocs.com/v2.0":
            iframe = 'https://apps.groupdocs.com/document-viewer/embed/' + upload.result.guid
        elif basePath == "https://dev-api.groupdocs.com/v2.0":
            iframe = 'https://dev-apps.groupdocs.com/document-viewer/embed/' + upload.result.guid
        elif basePath == "https://stage-api.groupdocs.com/v2.0":
            iframe = 'https://stage-apps.groupdocs.com/document-viewer/embed/' + upload.result.guid
        iframe = signer.signUrl(iframe)

    # If request was successfull - set variables for template
    return render_to_response('__main__:templates/sample24.pt', {
        'userId': clientId,
        'privateKey': privateKey,
        'url': url,
        'iframe': iframe,
    },
                              request=request)
コード例 #19
0
def sample34(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    folder = request.POST.get('folder')
    basePath = request.POST.get('server_type')
    # Checking clientId, privateKey and folder
    if IsNotNull(clientId) == False or IsNotNull(
            privateKey) == False or IsNotNull(folder) == False:
        return render_to_response('__main__:templates/sample34.pt',
                                  {'error': 'You do not enter all parameters'})
    #Remove tags and spaces from entered data
    clientId = re.sub('<[^>]*>', '', clientId.strip())
    privateKey = re.sub('<[^>]*>', '', privateKey.strip())
    folder = re.sub('<[^>]*>', '', folder.strip())
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
    basePath = re.sub('<[^>]*>', '', basePath)
    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storageApi = StorageApi(apiClient)
    storageApi.basePath = basePath
    ####Make a request to Storage API using clientId

    try:
        #Check entered path for propper slashes
        if folder.find("\\") != -1:
            folder = folder.replace("\\", "/")
        #Create folder
        createFolder = storageApi.Create(clientId, folder)
        #Check status
        if createFolder.status == "Ok":
            #If status Ok generate message with successful result
            message = '<span style="color:green">Folder was created ' + folder + '</span>'
        else:
            raise Exception(createFolder.error_message)
    except Exception, e:
        return render_to_response('__main__:templates/sample34.pt',
                                  {'error': str(e)})
コード例 #20
0
def sample34(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    folder = request.POST.get('folder')
    basePath = request.POST.get('basePath')
    # Checking clientId, privateKey and folder
    if not clientId or not privateKey or not folder:
        return render_to_response('__main__:templates/sample34.pt',
                                  dict(error='You do not enter all parameters'))
        #Remove tags and spaces from entered data
    clientId = re.sub('<[^>]*>', '', clientId.strip())
    privateKey = re.sub('<[^>]*>', '', privateKey.strip())
    folder = re.sub('<[^>]*>', '', folder.strip())
    if not basePath:
        basePath = "https://api.groupdocs.com/v2.0"
    basePath = re.sub('<[^>]*>', '', basePath)
    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    storageApi = StorageApi(apiClient)
    storageApi.basePath = basePath
    ####Make a request to Storage API using clientId

    try:
        #Check entered path for slashes
        if folder.find("\\") != -1:
            folder = folder.replace("\\", "/")
            #Create folder
        createFolder = storageApi.Create(clientId, folder)
        #Check status
        if createFolder.status == "Ok":
            #If status Ok generate message with successful result
            message = '<span style="color:green">Folder was created ' + folder + '</span>'
        else:
            raise Exception(createFolder.error_message)
    except Exception, e:
        return render_to_response('__main__:templates/sample34.pt',
                                  {'error': str(e)})
コード例 #21
0
def sample22(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileId = request.POST.get('fileId')
    guid = ""
    email = request.POST.get('email')
    name = request.POST.get('first_name')
    lastName = request.POST.get('last_name')

    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(email) == False or IsNotNull(name) == False or IsNotNull(lastName) == False:
        return render_to_response('__main__:templates/sample22.pt',
            { 'error' : 'You do not enter all parameters' })

    ### Create Signer, ApiClient and Mgmt Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create mgmtApi object
    mgmt = MgmtApi(apiClient)
    # Create StorageApi object
    storage = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    storage.basePath = basePath
    # Declare which server to use
    mgmt.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = storage.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response('__main__:templates/sample16.pt',
                { 'error' : str(e) })
コード例 #22
0
def sample08(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileId = request.POST.get('fileId')
    guid = ""
    pageNumber = request.POST.get('pageNumber') or 0
    #Checking parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample08.pt',
                                  { 'error' : 'You do not enter all parameters' })
    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create DocApi object
    docApi = DocApi(apiClient)
    #Create Storage Api object
    api = StorageApi(apiClient)
    ####Make request to DocApi using user id
    #Check base path
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    docApi.basePath = basePath
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response('__main__:templates/sample08.pt',
                { 'error' : str(e) })
コード例 #23
0
    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create StorageApi object
    storage = StorageApi(apiClient)
    # Create SignatureApi object
    signature = SignatureApi(apiClient)
    docApi = DocApi(apiClient)
    mergeApi = MergeApi(apiClient)
    asyncApi = AsyncApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
    #Set base path
    storage.basePath = basePath
    signature.basePath = basePath
    docApi.basePath = basePath
    mergeApi.basePath = basePath
    asyncApi.basePath = basePath
    guid = fileId
    #Create list with entered data
    enteredData = {
        "email": email,
        "country": country,
        "name": name,
        "street": street,
        "city": city
    }
    #Create new Datasource object
    dataSource = Datasource
コード例 #24
0
 #Create apiClient object
 apiClient = ApiClient(signer)
 #Create Storage Api object
 storage = StorageApi(apiClient)
 #Create AsyncApi object
 async = AsyncApi(apiClient)
 #Create MergeApi object
 merge = MergeApi(apiClient)
 #Create DocApi object
 doc = DocApi(apiClient)
 #Check is base path entered
 if not basePath:
     #If base path empty set base path to the dev server
     basePath = 'https://api.groupdocs.com/v2.0'
 #Set base path for api
 storage.basePath = basePath
 async.basePath = basePath
 merge.basePath = basePath
 doc.basePath = basePath
 try:
     #Get all fields from document
     getFields = doc.GetTemplateFields(clientId, fileGuid)
     if getFields.status == "Ok":
         allFields = getFields.result.fields
         #Create Datasource object
         dataSource = Datasource()
         #Create empty list
         fieldsList = []
         counter = -1
         value = []
         for field in allFields:
コード例 #25
0
            except Exception, e:
                print e
    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create ComparisonApi object
    compare = ComparisonApi(apiClient)
    api = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    compare.basePath = basePath
    if url != "" or target_url != "":
        if url != "":
            try:
                # Upload file to current user storage using entere URl to the file
                upload = api.UploadWeb(clientId, url)
                sourceFileId = upload.result.guid

            except Exception, e:
                return render_to_response('__main__:templates/sample19.pt',
                    { 'error' : str(e) })
        if target_url != "":
            try:
                # Upload file to current user storage using entere URl to the file
                upload = api.UploadWeb(clientId, target_url)
コード例 #26
0
def sample41(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    fileId = request.POST.get('fileId')
    callbackUrl = request.POST.get('callbackUrl')
    emailsArray = request.POST.getall('email[]')
    guid = None
    iframe = None
    # Checking required parameters
    if not clientId or not privateKey or not emailsArray:
        return render_to_response('__main__:templates/sample41.pt',
                                  dict(error='You do not enter all parameters'))
    #Get current work directory
    currentDir = os.path.dirname(os.path.realpath(__file__))
    #Create text file
    fp = open(currentDir + '/../user_info.txt', 'w')
    #Write user info to text file
    fp.write(clientId + "\r\n" + privateKey)
    fp.close()
    #Check if last list element is empty string
    if emailsArray[1] == '':
        #Remove empty element from list
        del emailsArray[1]
    ### Create Signer, ApiClient and Annotation Api objects
    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create StorageApi object
    storage = StorageApi(apiClient)
    mgmtApi = MgmtApi(apiClient)
    antApi = AntApi(apiClient)
    if not basePath:
        basePath = "https://api.groupdocs.com/v2.0"
        #Set base path
    storage.basePath = basePath
    mgmtApi.basePath = basePath
    if url:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = storage.UploadWeb(clientId, url)
            guid = upload.result.guid
            try:
                ####Make a request to Storage API using clientId

                #Obtaining all Entities from current user
                files = storage.ListEntities(userId=clientId, path='My Web Documents', pageIndex=0)
                #Obtaining file name
                for item in files.result.files:
                    #selecting file names
                    if item.guid == guid:
                        fileName = item.name

            except Exception, e:
                return render_to_response('__main__:templates/sample41.pt',
                                          {'error': str(e)})
            fileId = None
        except Exception, e:
            return render_to_response('__main__:templates/sample41.pt',
                                      {'error': str(e)})
コード例 #27
0
def sample42(request):
    clientId = request.POST.get("clientId")
    privateKey = request.POST.get("privateKey")
    fileId = request.POST.get("fileId")
    basePath = request.POST.get("basePath")
    iframe = None
    # Checking clientId, privateKey and fileId
    if not clientId or not privateKey or not fileId:
        return render_to_response("__main__:templates/sample42.pt", dict(error="You do not enter all parameters"))

    ####Create Signer, ApiClient and Storage Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Ant Api object
    antApi = AntApi(apiClient)
    # Create Storage Api object
    storageApi = StorageApi(apiClient)
    # Create Async api object
    asyncApi = AsyncApi(apiClient)
    # Set base Path
    if not basePath:
        basePath = "https://api.groupdocs.com/v2.0"
    antApi.basePath = basePath
    asyncApi.basePath = basePath
    storageApi.basePath = basePath
    try:
        # Get all annotations from document
        getAllAnnotations = antApi.ListAnnotations(clientId, fileId)
        if getAllAnnotations.status == "Ok":
            # Create list of result document type
            convertType = ["pdf"]
            # Create JobInfo object and set attributes
            jobInfo = JobInfo()
            jobInfo.actions = "ImportAnnotations"
            jobInfo.out_formats = convertType
            jobInfo.status = "-1"
            jobInfo.email_results = True
            rand = random.randint(0, 500)
            jobInfo.name = "test" + str(rand)
            # Create job
            createJob = asyncApi.CreateJob(clientId, jobInfo)
            if createJob.status != "Ok":
                raise Exception(createJob.error_message)
            else:
                # Add document to the job
                addJobDocument = asyncApi.AddJobDocument(clientId, createJob.result.job_id, fileId, False)
                if addJobDocument.status != "Ok":
                    raise Exception(addJobDocument.error_message)
                else:
                    # Change job status
                    jobInfo.status = "0"
                    # Update job with new status
                    updateJob = asyncApi.UpdateJob(clientId, createJob.result.job_id, jobInfo)
                    if updateJob.status != "Ok":
                        raise Exception(updateJob.error_message)
                    time.sleep(5)
                    # Get result file from job by it's ID
                    getJobDocument = asyncApi.GetJobDocuments(clientId, createJob.result.job_id)

                    if getJobDocument.status != "Ok":
                        raise Exception(getJobDocument.error_message)
                    else:
                        # Get document GUID and Name from job
                        fileGuid = getJobDocument.result.inputs[0].outputs[0].guid
                        fileName = getJobDocument.result.inputs[0].outputs[0].name
                        # Obtaining file stream of downloading file and definition of folder where to download file
                        # Clear downloads folder
                        currentDir = os.path.dirname(os.path.realpath(__file__))
                        if os.path.isdir(currentDir + "/../downloads"):
                            # Get list of files
                            for the_file in os.listdir(currentDir + "/../downloads"):
                                file_path = os.path.join(currentDir + "/../downloads", the_file)
                                try:
                                    # Delete file from folder
                                    os.unlink(file_path)
                                except Exception, e:
                                    print e
                        # Set path to were file will be downloaded
                        newPath = currentDir + "/../downloads/"
                        if not os.path.exists(newPath):
                            os.makedirs(newPath)
                        # Downlaoding of file
                        fs = storageApi.GetFile(clientId, fileGuid)
                        if fs:
                            # Write file from stream to the downloads folder
                            filePath = newPath + fileName
                            with open(filePath, "wb") as fp:
                                shutil.copyfileobj(fs.inputStream, fp)
                            # Generate template message with link by clicking on which user can download file to he's local machine
                            message = (
                                '<p><span style="color:green">File with annotations was downloaded to server\'s local folder. You can download it from <a href="/download_file?FileName='
                                + fileName
                                + '">here</a></span></p>'
                            )
                            # Generation of iframe URL using $pageImage->result->guid
                            # iframe to production server
                            if basePath == "https://api.groupdocs.com/v2.0":
                                iframe = "https://apps.groupdocs.com/document-viewer/embed/" + fileGuid
                            # iframe to dev server
                            elif basePath == "https://dev-api.groupdocs.com/v2.0":
                                iframe = "https://dev-apps.groupdocs.com/document-viewer/embed/" + fileGuid
                            # iframe to test server
                            elif basePath == "https://stage-api.groupdocs.com/v2.0":
                                iframe = "https://stage-apps.groupdocs.com/document-viewer/embed/" + fileGuid
                            elif basePath == "http://realtime-api.groupdocs.com":
                                iframe = "http://realtime-apps.groupdocs.com/document-viewer/embed/" + fileGuid
                            iframe = signer.signUrl(iframe)
                        else:
                            raise Exception("Wrong file ID!")
        else:
コード例 #28
0
            except Exception, e:
                print e
    ### Create Signer, ApiClient and AsyncApi objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create AsyncApi object
    async = AsyncApi(apiClient)
    # Create Storage object
    api = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    async.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response('__main__:templates/sample16.pt',
                { 'error' : str(e) })

    if inputFile != "":
        try:
            #A hack to get uploaded file size
            inputFile.file.seek(0, 2)
コード例 #29
0
def sample45(request):
    # Set variables and get POST data
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    folderName = request.POST.get('folderName')
    fileName = request.POST.get('fileName')
    basePath = request.POST.get('basePath')
    # Checking required parameters
    if not clientId or not privateKey or not fileName:
        return render_to_response('__main__:templates/sample45.pt',
                                  dict(error='You do not enter all parameters'))

    ### Create Signer, ApiClient, StorageApi and Document Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create DocApi object
    doc = DocApi(apiClient)
    #Create Storage object
    storage = StorageApi(apiClient)
    #Check base path
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
    #Set base path
    doc.basePath = basePath
    storage.basePath = basePath
    try:
        #Check folder name
        if not folderName:
            folderName = ''
        #Get all files
        allFiles = storage.ListEntities(clientId, folderName)
        if allFiles.status == "Ok":
            #Fet file guid by it's name
            for item in allFiles.result.files:
                if item.name == fileName:
                    guid = item.guid
            #Get document info
            documentInfo = doc.GetDocumentMetadata(clientId, guid)
            if documentInfo.result is not None:
                #Generate table with statistic data
                result = "<table class='border'>"
                result += "<tr><td><font color='green'>Parameter</font></td><td><font color='green'>Info</font></td></tr>"
                for item in documentInfo.result.__dict__:
                    if item != 'swaggerTypes':
                        if type(documentInfo.result.__dict__[item]).__name__ == 'instance':
                            for key in documentInfo.result.__dict__[item].__dict__:
                                if key != 'swaggerTypes':
                                    if type(documentInfo.result.__dict__[item].__dict__[key]).__name__ == 'instance':
                                        for value in documentInfo.result.__dict__[item].__dict__[key].__dict__:
                                            if value != "swaggerTypes":
                                                result += "<tr><td>" +  value + "</td><td>" + unicode(documentInfo.result.__dict__[item].__dict__[key].__dict__[value]) + "</td></tr>"
                                    else:
                                        result += "<tr><td>" + key + "</td><td>" + unicode(documentInfo.result.__dict__[item].__dict__[key]) + "</td></tr>"
                        else:
                            result += "<tr><td>" + item + "</td><td>" + unicode(documentInfo.result.__dict__[item]) + "</td></tr>"
                result += "</table>"

    except Exception, e:
        return render_to_response('__main__:templates/sample45.pt',
                                  dict(error=str(e)))