Skip to content

Commit ba525b4

Browse files
committed
Fix build issue about upload file.
1 parent 946b259 commit ba525b4

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

asposecellscloud/requests/upload_file_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def create_http_request(self, api_client):
6969
for filename , filecontext in self.upload_files.items():
7070
local_var_files[filename] = filecontext
7171
else:
72-
if isinstance(self.file,bytes):
72+
if isinstance(self.upload_files,bytes):
7373
local_var_files['File'] = self.upload_files
7474
else:
7575
local_var_files['UploadFiles'] = self.upload_files

test/AuthUtil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
from asposecellscloud.requests.upload_file_request import UploadFileRequest
3737

3838
grantType = "client_credentials"
39-
clientId = os.getenv('CellsCloudTestClientId')
40-
clientSecret = os.getenv('CellsCloudTestClientSecret')
39+
clientId = os.getenv('CellsCloudClientId')
40+
clientSecret = os.getenv('CellsCloudClientSecret')
4141
def GetBaseUrl():
42-
return os.getenv('CellsCloudTestApiBaseUrl')
42+
return os.getenv('CellsCloudApiBaseUrl')
4343
def GetClientId():
4444
return clientId
4545
def GetClientSecret():

test/tests_one.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,35 @@ def setUp(self):
3030
global_api = CellsApi(AuthUtil.GetClientId(),AuthUtil.GetClientSecret(),"v3.0",AuthUtil.GetBaseUrl())
3131
self.api = global_api
3232
def test_one_case(self):
33-
cellsApi = CellsApi(AuthUtil.GetClientId(),AuthUtil.GetClientSecret())
34-
convertOption = ConvertWorkbookOptions ()
35-
convertOption.convert_format = 'png'
36-
convertOption.file_info = FileInfo()
37-
convertOption.file_info.filename = "Book1.xlsx"
38-
with open("TestData/Book1.xlsx", "rb") as excel_file:
39-
convertOption.file_info.file_content = base64.b64encode(excel_file.read()).decode("utf-8")
40-
convertOption.page_setup = PageSetup()
41-
convertOption.page_setup.print_headings = True
42-
convertWorkbookRequest = PostConvertWorkbookRequest(convertOption)
43-
fileInfo = cellsApi.post_convert_workbook(convertWorkbookRequest)
44-
file_bytes = base64.b64decode(fileInfo.file_content)
45-
46-
with open(fileInfo.filename, "wb") as f:
47-
f.write(file_bytes)
33+
remote_folder = 'TestData/In'
34+
35+
local_name = 'Book1.xlsx'
36+
remote_name = 'Book1.xlsx'
37+
38+
result = AuthUtil.Ready(self.api, local_name, remote_folder + '/' + remote_name, '')
39+
self.assertTrue(len(result.uploaded) > 0)
40+
41+
request = PutWorksheetFilterRequest(remote_name, 'Sheet1', 'A1:B1', 0, 'Year', match_blanks=False, refresh=True,
42+
folder=remote_folder, storage_name='')
43+
self.api.put_worksheet_filter(request)
44+
45+
# cellsApi = CellsApi(AuthUtil.GetClientId(),AuthUtil.GetClientSecret())
46+
# convertOption = ConvertWorkbookOptions ()
47+
# convertOption.convert_format = 'png'
48+
# convertOption.file_info = FileInfo()
49+
# convertOption.file_info.filename = "Book1.xlsx"
50+
# with open("TestData/Book1.xlsx", "rb") as excel_file:
51+
# convertOption.file_info.file_content = base64.b64encode(excel_file.read()).decode("utf-8")
52+
# convertOption.page_setup = PageSetup()
53+
# convertOption.page_setup.print_headings = True
54+
# convertWorkbookRequest = PostConvertWorkbookRequest(convertOption)
55+
# fileInfo = cellsApi.post_convert_workbook(convertWorkbookRequest)
56+
# file_bytes = base64.b64decode(fileInfo.file_content)
57+
#
58+
# with open(fileInfo.filename, "wb") as f:
59+
# f.write(file_bytes)
60+
61+
4862
# remote_folder = 'TestData/In'
4963

5064

0 commit comments

Comments
 (0)