예제 #1
0
def upload(request):
	client_id = request.POST['client_id']
	private_key = request.POST['private_key']
	
	input_file = request.POST['file']

	
	current_dir = os.path.dirname(os.path.realpath(__file__))

	# Using the filename like this without cleaning it is very
	# insecure so please keep that in mind when writing your own
	# file handling.
	file_path = os.path.join(current_dir, input_file.filename)
	output_file = open(file_path, 'wb')

	input_file.file.seek(0)
	while 1:
		data = input_file.file.read(2<<16)
		if not data:
			break
		output_file.write(data)
	output_file.close()	
	
	signer = GroupDocsRequestSigner(private_key)
	apiClient = ApiClient(signer)
	api = StorageApi(apiClient)

	fs = FileStream.fromFile(file_path);
	response = api.Upload(client_id, input_file.filename, fs)
	fs.inputStream.close()
	os.remove(file_path)
	return render_to_response('__main__:viewer.pt',
                              {'guid':response.result.guid},
                              request=request)
예제 #2
0
def upload(request):
    client_id = request.POST['client_id']
    private_key = request.POST['private_key']

    input_file = request.POST['file']

    current_dir = os.path.dirname(os.path.realpath(__file__))

    # Using the filename like this without cleaning it is very
    # insecure so please keep that in mind when writing your own
    # file handling.
    file_path = os.path.join(current_dir, input_file.filename)
    output_file = open(file_path, 'wb')

    input_file.file.seek(0)
    while 1:
        data = input_file.file.read(2 << 16)
        if not data:
            break
        output_file.write(data)
    output_file.close()

    signer = GroupDocsRequestSigner(private_key)
    apiClient = ApiClient(signer)
    api = StorageApi(apiClient)

    fs = FileStream.fromFile(file_path)
    response = api.Upload(client_id, input_file.filename, fs)
    fs.inputStream.close()
    os.remove(file_path)
    return render_to_response('__main__:viewer.pt',
                              {'guid': response.result.guid},
                              request=request)
 def setUp(self):
     filePath = os.path.dirname(os.path.abspath(__file__)) + "/resources/test.doc"
     self.fs = FileStream.fromFile(filePath) 
 def setUp(self):
     filePath = os.path.dirname(
         os.path.abspath(__file__)) + "/resources/test.doc"
     self.fs = FileStream.fromFile(filePath)