Skip to content

Commit 707925f

Browse files
update to 24.3
1 parent 6f874f7 commit 707925f

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
3030
## Read PDF Formats
3131
MHT, PCL, PS, XSLFO, MD
3232

33-
## Enhancements in Version 24.2
34-
- Memory leak when converting PDF to DOCX.
33+
## Enhancements in Version 24.3
3534
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3635

3736
## Requirements.
@@ -68,13 +67,18 @@ import asposepdfcloud
6867
```python
6968
# Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
7069
pdf_api_client = asposepdfcloud.ApiClient('MY_CLIENT_ID', 'MY_CLIENT_SECRET')
71-
7270
pdf_api = asposepdfcloud.PdfApi(pdf_api_client)
73-
7471
file_name = 'PdfWithAnnotations.pdf'
7572
page_number = 2
7673
response = pdf_api.get_page_annotations(file_name, page_number, folder=temp_folder)
7774
```
75+
76+
## SelfHost Aspose.PDF Cloud
77+
Create **ApiClient** object without **app_key** and **app_sid** parameters, but with **host** parameter set to *url of SelfHost Aspose.PDF Cloud* and **self_host** parameter set to *True*:
78+
```python
79+
pdf_api_client = asposepdfcloud.ApiClient('', '', 'MY_SELFHOST_URL', True)
80+
```
81+
7882
## Unit Tests
7983
Aspose PDF SDK includes a suite of unit tests within the "test" subdirectory. These Unit Tests also serves as examples of how to use the Aspose PDF SDK.
8084

asposepdfcloud/api_client.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ class ApiClient(object):
7676
'object': object,
7777
}
7878

79-
def __init__(self, app_key, app_sid, host=None):
79+
def __init__(self, app_key, app_sid, host=None, self_host=False):
8080
"""
8181
Constructor of the class.
8282
"""
8383
self.rest_client = RESTClientObject()
8484
self.default_headers = {}
8585
self.default_headers['x-aspose-client'] = 'python sdk'
86-
self.default_headers['x-aspose-client-version'] = '24.2.0'
86+
self.default_headers['x-aspose-client-version'] = '24.3.0'
8787

88+
self.self_host = self_host
8889
self.app_key = app_key
8990
self.app_sid = app_sid
9091

@@ -175,12 +176,11 @@ def __call_api(self, resource_path, method,
175176
# request url
176177
url = self.host + resource_path
177178

178-
179-
# OAuth2.0 authentication
180-
if Configuration().access_token == "":
181-
self.__request_token()
182-
183-
self.__add_o_auth_token(header_params)
179+
if not self.self_host:
180+
# OAuth2.0 authentication
181+
if Configuration().access_token == "":
182+
self.__request_token()
183+
self.__add_o_auth_token(header_params)
184184

185185
response_data = None
186186

@@ -194,9 +194,10 @@ def __call_api(self, resource_path, method,
194194
_request_timeout=_request_timeout)
195195
except ApiException as error:
196196
if error.status == 401:
197-
self.__request_token()
198-
self.__add_o_auth_token(header_params)
199-
response_data = self.request(method, url,
197+
if not self.self_host:
198+
self.__request_token()
199+
self.__add_o_auth_token(header_params)
200+
response_data = self.request(method, url,
200201
query_params=query_params,
201202
headers=header_params,
202203
post_params=post_params, body=body,

asposepdfcloud/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,5 @@ def to_debug_report(self):
199199
"OS: {env}\n"\
200200
"Python Version: {pyversion}\n"\
201201
"Version of the API: 3.0\n"\
202-
"SDK Package Version: 24.2.0".\
202+
"SDK Package Version: 24.3.0".\
203203
format(env=sys.platform, pyversion=sys.version)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from setuptools import setup, find_packages
3333

3434
NAME = "asposepdfcloud"
35-
VERSION = "24.2.0"
35+
VERSION = "24.3.0"
3636
# To install the library, run the following
3737
#
3838
# python setup.py install

test/pdf_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def setUp(self):
5050
data = json.load(json_file)
5151

5252
self.pdf_api_client = asposepdfcloud.api_client.ApiClient(
53-
app_key=str(data['AppKey']),
54-
app_sid=str(data['AppSID']),
55-
host=str(data['ProductUri']))
53+
app_key=str(data.get('AppKey', '')),
54+
app_sid=str(data.get('AppSID', '')),
55+
host=str(data['ProductUri']),
56+
self_host=bool(data.get('SelfHost', False)),
57+
)
5658

5759
self.pdf_api = PdfApi(self.pdf_api_client)
58-
5960
self.output_path = str(data['OutputLocation'])
60-
6161
self.temp_folder = 'TempPdfCloud'
6262
self.test_data_path = 'test_data/'
6363

0 commit comments

Comments
 (0)