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)))
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 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 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)))
# 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 array = [] #Create DataSourceField object and filing it with entered data for key, data in enteredData.iteritems():
#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: #Create DatasourceField object and set data to it for fieldName, fieldContent in dataForMerge.iteritems():
# 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 array = [] #Create DataSourceField object and filing it with entered data for key, data in enteredData.iteritems(): value = [data] field = DatasourceField() field.name = key field.type = "text" field.values = value array.append(field)