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)})
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)})
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)})
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)
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) targetFileId = upload.result.guid except Exception, e: return render_to_response('__main__:templates/sample19.pt', { 'error' : str(e) }) if sourceFile != "" or targetFile != "":
signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create StorageApi object storage = StorageApi(apiClient) # Create SignatureApi object signature = SignatureApi(apiClient) if basePath == "": basePath = 'https://api.groupdocs.com/v2.0' #Set base path storage.basePath = basePath signature.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 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: