Esempio n. 1
0
def sample15(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')

    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample15.pt',
                                  {'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)

    # set total views
    views = 0

    try:
        # Make a request to Document API
        response = doc.GetDocumentViews(clientId)
        if response.status == "Ok":
            views = len(response.result.views)

    except Exception, e:
        return render_to_response('__main__:templates/sample15.pt',
                                  {'error': str(e)})
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)))
Esempio n. 3
0
def sample14(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    path = request.POST.get('path')

    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(
            privateKey) == False or IsNotNull(path) == False:
        return render_to_response('__main__:templates/sample14.pt',
                                  {'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 StorageApi object
    storageApi = StorageApi(apiClient)
    # Create DocApi object
    docApi = DocApi(apiClient)

    # initialization some variables
    folderId = None
    users = ""

    # parse input path
    pathList = path.split('/')
    if len(path) > 1:
        last = pathList[-1]
        del pathList[-1]
        newPath = "/".join(pathList)
    else:
        last = pathList.pop(0)
        newPath = ""

    try:
        #### Get folder ID by path

        # Make a request to Storage API
        list = storageApi.ListEntities(clientId, newPath)
        if list.status == "Ok":
            for folder in list.result.folders:
                if (folder.name == last):
                    folderId = folder.id

        ### Get list of shares
        if folderId is not None:
            # Make a request to Document API
            shares = docApi.GetFolderSharers(clientId, int(folderId))
            if shares.status == "Ok" and len(shares.result.shared_users) > 0:
                for x in xrange(len(shares.result.shared_users)):
                    # construct users list
                    users += str(shares.result.shared_users[x].nickname)
                    if x != len(shares.result.shared_users) - 1:
                        users += ", "

    except Exception, e:
        return render_to_response('__main__:templates/sample14.pt',
                                  {'error': str(e)})
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= ''))
Esempio n. 5
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)})
Esempio n. 6
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) })
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=''))
def sample23(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    fileId = request.POST.get('fileId')
    basePath = request.POST.get('server_type')

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

    ### Create Signer, ApiClient and Doc Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create DocApi object
    doc = DocApi(apiClient)
    # Set url to choose whot server to use
    doc.basePath = basePath

    # Make request yo the Api to get images for all document pages
    pageImage = doc.ViewDocument(clientId, fileId, pageNumber=0, pageCount=-1, width=100)

    # Check the result of the request
    if pageImage.status == "Ok":
        # Generation of iframe URL using pageImage.result.guid
        if basePath == "https://api.groupdocs.com/v2.0":
            iframe = '<iframe src="https://apps.groupdocs.com/document-viewer/embed/' + pageImage.result.guid + '?frameborder="0" width="720" height="600"></iframe>'
        elif basePath == "https://dev-api.groupdocs.com/v2.0":
            iframe = '<iframe src="https://dev-apps.groupdocs.com/document-viewer/embed/' + pageImage.result.guid + '?frameborder="0" width="720" height="600"></iframe>'
        elif basePath == "https://stage-api.groupdocs.com/v2.0":
            iframe = '<iframe src="https://stage-apps.groupdocs.com/document-viewer/embed/' + pageImage.result.guid + '?frameborder="0" width="720" height="600"></iframe>'


    # If request was successfull - set variables for template
    return render_to_response('__main__:templates/sample23.pt',
        {
            'userId' : clientId,
            'privateKey' : privateKey,
            'fileId' : fileId,
            'iframe' : iframe
        },
        request=request)
def sample43(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    fileId = request.POST.get('fileId')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    message = None
    iframe = None
    # Checking clientId and privateKey
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample43.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 Doc Api object
    docApi = DocApi(apiClient)
    #Create Storage Api object
    storageApi = StorageApi(apiClient)
    #Create Async api object
    asyncApi = AsyncApi(apiClient)
    #Create Merge api object
    mergeApi = MergeApi(apiClient)
    #Set base Path
    if not basePath:
        basePath = "https://api.groupdocs.com/v2.0"
    docApi.basePath = basePath
    mergeApi.basePath = basePath
    asyncApi.basePath = basePath
    storageApi.basePath = basePath
    if url:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = storageApi.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = None
        except Exception, e:
            return render_to_response('__main__:templates/sample43.pt',
                dict(error=str(e)))
Esempio n. 10
0
def sample23(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    urlUpload = request.POST.get('url')
    basePath = request.POST.get('basePath')
    fileId = request.POST.get('fileId')
    guid = ""
    image = ""

    # Checking required parameters
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample23.pt',
                                  dict(error='You do not enter all parameters'))

    ### Create Signer, ApiClient and Doc Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create DocApi object
    doc = DocApi(apiClient)
    # Create StorageApi object
    storage = StorageApi(apiClient)
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    storage.basePath = basePath
    # Set url to choose what server to use
    doc.basePath = basePath
    if urlUpload:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = storage.UploadWeb(clientId, urlUpload)
            guid = upload.result.guid
            fileId = None
        except Exception, e:
            return render_to_response('__main__:templates/sample23.pt',
                                      dict(error=str(e)))
Esempio n. 11
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) })
Esempio n. 12
0
def sample23(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    urlUpload = request.POST.get('url')
    basePath = request.POST.get('server_type')
    fileId = request.POST.get('fileId')
    guid = ""

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

    ### Create Signer, ApiClient and Doc Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create DocApi object
    doc = DocApi(apiClient)
    # Create StorageApi object
    storage = StorageApi(apiClient)
    if basePath == "":
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    storage.basePath = basePath
    # Set url to choose whot server to use
    doc.basePath = basePath
    if urlUpload != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = storage.UploadWeb(clientId, urlUpload)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response('__main__:templates/sample23.pt',
                                      {'error': str(e)})
Esempio n. 13
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)})
Esempio n. 14
0
def sample23(request):
    clientId = request.POST.get("client_id")
    privateKey = request.POST.get("private_key")
    inputFile = request.POST.get("file")
    urlUpload = request.POST.get("url")
    basePath = request.POST.get("server_type")
    fileId = request.POST.get("fileId")
    guid = ""

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

    ### Create Signer, ApiClient and Doc Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create DocApi object
    doc = DocApi(apiClient)
    # Create StorageApi object
    storage = StorageApi(apiClient)
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
        # Set base path
    storage.basePath = basePath
    # Set url to choose whot server to use
    doc.basePath = basePath
    if urlUpload != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = storage.UploadWeb(clientId, urlUpload)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response("__main__:templates/sample23.pt", {"error": str(e)})
Esempio n. 15
0
                #Delete file from folder
                os.unlink(file_path)

            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 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,
Esempio n. 16
0
 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, 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
 try:
     #Get all fields from document
     getFields = doc.GetTemplateFields(clientId, fileGuid)
     if getFields.status == "Ok":
         allFields = getFields.result.fields
         #Create Datasource object
Esempio n. 17
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)))
Esempio n. 18
0
                #Delete file from folder
                os.unlink(file_path)

            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 StorageApi object
    storage = StorageApi(apiClient)
    # Create SignatureApi object
    signature = SignatureApi(apiClient)
    docApi = DocApi(apiClient)
    mergeApi = MergeApi(apiClient)
    asyncApi = AsyncApi(apiClient)
    if not 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 = templateGuid
    #Create list with entered data
    enteredData = {"email": email, "country": country, "name": name, "street": street, "city": city}
    #Create new Datasource object
    dataSource = Datasource