Skip to content

Commit

Permalink
update 3.23.12
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtingwei998 committed Jan 4, 2024
1 parent a185839 commit 0345664
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/obs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
Expand Down
7 changes: 3 additions & 4 deletions src/obs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,12 +1759,11 @@ def putFile(self, bucketName, objectKey, file_path, metadata=None, headers=None,
metadata = dict()

if _flag:
headers['contentLength'] = None
headers['md5'] = None
headers['contentType'] = None

results = []
for f in os.listdir(file_path):
headers['contentLength'] = None
headers['md5'] = None
headers['contentType'] = None
f = util.safe_encode(f)
__file_path = os.path.join(file_path, f)
if not const.IS_PYTHON2:
Expand Down
2 changes: 1 addition & 1 deletion src/obs/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
DEFAULT_TASK_NUM = 8
DEFAULT_TASK_QUEUE_SIZE = 20000

OBS_SDK_VERSION = '3.23.9'
OBS_SDK_VERSION = '3.23.12'

V2_META_HEADER_PREFIX = 'x-amz-meta-'
V2_HEADER_PREFIX = 'x-amz-'
Expand Down
2 changes: 1 addition & 1 deletion src/obs/convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Adapter(object):
OBS_ALLOWED_STORAGE_CLASS = ['STANDARD', 'WARM', 'COLD']
V2_ALLOWED_STORAGE_CLASS = ['STANDARD', 'STANDARD_IA', 'GLACIER']

OBS_ALLOWED_GROUP = ['Everyone']
OBS_ALLOWED_GROUP = ['Everyone','AuthenticatedUsers','LogDelivery']
V2_ALLOWED_GROUP = ['http://acs.amazonaws.com/groups/global/AllUsers',
'http://acs.amazonaws.com/groups/global/AuthenticatedUsers',
'http://acs.amazonaws.com/groups/s3/LogDelivery']
Expand Down
14 changes: 13 additions & 1 deletion src/obs/crypto_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import io

Expand Down
15 changes: 14 additions & 1 deletion src/obs/obs_cipher_suite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import binascii
import hashlib
import os
Expand Down
11 changes: 11 additions & 0 deletions src/obs/posix_transfer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from obs.ilog import DEBUG, ERROR, INFO
from obs.model import DeleteObjectsRequest, Object
Expand Down
5 changes: 3 additions & 2 deletions src/obs/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

# http://www.apache.org/licenses/LICENSE-2.0

import functools
import json
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import functools
import json
import math
import operator
import os
Expand Down
1 change: 1 addition & 0 deletions src/obs/workflow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
Expand Down
4 changes: 2 additions & 2 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

setup(
name='esdk-obs-python',
version='3.23.9',
version='3.23.12',
packages=find_packages(exclude=['tests']),
zip_safe=False,
description='OBS Python SDK',
long_description='OBS Python SDK',
license='Apache-2.0',
keywords=('obs', 'python'),
install_requires=[
'pycryptodome==3.10.1'
'pycryptodome>=3.10.1'
],
platforms='Independant',
url='',
Expand Down
14 changes: 13 additions & 1 deletion src/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
15 changes: 14 additions & 1 deletion src/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import hashlib
import json
import os
Expand Down
15 changes: 14 additions & 1 deletion src/tests/test_crypto_obs_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import hashlib
import io
import os
Expand Down
14 changes: 13 additions & 1 deletion src/tests/test_ctr_crypto_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import pytest

Expand Down
39 changes: 38 additions & 1 deletion src/tests/test_obs_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import io
import os
import random
Expand Down Expand Up @@ -386,6 +399,30 @@ def test_uploadFile_with_metadata(self):
assert meta_dict["meta_key1"] == "value1"
assert meta_dict["meta_key-2"] == "value-2"

def test_putFile_with_content_type(self):
# 测试使用putFile上传文件夹content-Type是否前后一致
client_type, uploadClient, downloadClient = self.get_client()
object_list = ['test.pdf', 'test.png', 'test.txt']
old_content_list = ['application/pdf', 'image/png', 'text/plain']
new_content_list = []
folder_name = "test_putFile_with_content_type"
folder = test_config["path_prefix"] + folder_name
if not os.path.exists(folder):
os.makedirs(folder)
for f in object_list:
object_name = folder_name + '/' + f
conftest.gen_random_file(object_name, 1024)

put_result = uploadClient.putFile(test_config["bucketName"], folder_name, folder)
for res in put_result:
assert res[1].status == 200
object_metadata = uploadClient.getObjectMetadata(test_config["bucketName"], res[0])
new_content_list.append(object_metadata.body.contentType)

assert new_content_list == old_content_list



def test_setBucketLifecycle_and_getBucketLifecycle_success(self):
client_type, bucketLifecycleClient, obsClient = self.get_client()
rule1 = Rule(id='rule1', prefix='prefix1', status='Enabled', expiration=Expiration(days=60),
Expand Down
15 changes: 14 additions & 1 deletion src/tests/test_rsa_crypto_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import pytest

from obs import CryptoObsClient, CtrRSACipherGenerator
Expand Down
15 changes: 14 additions & 1 deletion src/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding:utf-8
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Copyright 2019 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

import os
import random
import unittest
Expand Down

0 comments on commit 0345664

Please sign in to comment.