sharedkernel 2.11.2__tar.gz → 2.11.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/PKG-INFO +3 -1
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/README.md +161 -159
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/setup.py +1 -1
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/s3_uploader.py +56 -15
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel.egg-info/PKG-INFO +3 -1
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/setup.cfg +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/chunker/chunk_rule.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/chunker/text_chunker.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/common.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/config.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/data_format_converter.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/__init__.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/audit_model.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/cache/__init__.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/cache/cache_repository.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/cache/redis_generic_cache.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/distributed_cache.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/mongo_generic_audit_repository.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/mongo_generic_repository.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/mongo_health_checker.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/pagination_response_dto.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/date_converter.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/diff_utils.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/encryption_service.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/__init__.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/error_code.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/feature_display_type.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/feature_key.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/order_type.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/plan_interval.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/plan_type.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/redis_mode_enum.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/sort_order.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/enum/user_role.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/exception/__init__.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/exception/exception.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/exception/exception_handlers.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/file_validation.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/ip_session_service.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/jwt_service.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/logger/log_decorator.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/logger/log_dto.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/logger/log_enums.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/logger/log_info.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/logger/log_middlewares.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/logger/logger_service.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/multipart_upload.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/normalizer/__init__.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/normalizer/number_normalizer.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/normalizer/phone_number_normalizer.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/normalizer/string_normalizer.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/__init__.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/base_document.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/json_string_model.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/jwt_model.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/result.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/subscription.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/user_info.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/objects/user_workspace.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/regex_masking.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/string_extentions.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/toolbox_service.py +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel.egg-info/SOURCES.txt +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel.egg-info/dependency_links.txt +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel.egg-info/requires.txt +0 -0
- {sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sharedkernel
|
|
3
|
-
Version: 2.11.
|
|
3
|
+
Version: 2.11.3
|
|
4
4
|
Summary: sharekernel is a shared package between all python projects
|
|
5
5
|
Author: Smilinno
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -33,6 +33,8 @@ Dynamic: summary
|
|
|
33
33
|
this is a shared kernel package
|
|
34
34
|
|
|
35
35
|
# Change Log
|
|
36
|
+
### Version 2.11.3
|
|
37
|
+
- Add S3Uploader.download, which reads an object from S3 using its URL
|
|
36
38
|
### Version 2.11.2
|
|
37
39
|
- Minor fix versioning
|
|
38
40
|
### Version 2.11.1
|
|
@@ -1,159 +1,161 @@
|
|
|
1
|
-
# SharedKernel
|
|
2
|
-
this is a shared kernel package
|
|
3
|
-
|
|
4
|
-
# Change Log
|
|
5
|
-
### Version 2.11.
|
|
6
|
-
-
|
|
7
|
-
### Version 2.11.
|
|
8
|
-
-
|
|
9
|
-
### Version 2.11.
|
|
10
|
-
-
|
|
11
|
-
### Version 2.
|
|
12
|
-
-
|
|
13
|
-
### Version 2.
|
|
14
|
-
-
|
|
15
|
-
### Version 2.9.
|
|
16
|
-
-
|
|
17
|
-
### Version 2.9.
|
|
18
|
-
-
|
|
19
|
-
### Version 2.9.
|
|
20
|
-
- add check_access_level to toolbox
|
|
21
|
-
### Version 2.9.
|
|
22
|
-
-
|
|
23
|
-
### Version 2.
|
|
24
|
-
- Add
|
|
25
|
-
### Version 2.
|
|
26
|
-
- Add
|
|
27
|
-
### Version 2.
|
|
28
|
-
- Add
|
|
29
|
-
### Version 2.6.
|
|
30
|
-
-
|
|
31
|
-
### Version 2.6.
|
|
32
|
-
-
|
|
33
|
-
### Version 2.6.
|
|
34
|
-
-
|
|
35
|
-
### Version 2.6.
|
|
36
|
-
-
|
|
37
|
-
### Version 2.
|
|
38
|
-
-
|
|
39
|
-
### Version 2.5.
|
|
40
|
-
-
|
|
41
|
-
### Version 2.5.
|
|
42
|
-
- Add
|
|
43
|
-
### Version 2.5.
|
|
44
|
-
-
|
|
45
|
-
### Version 2.5.
|
|
46
|
-
- fix bug
|
|
47
|
-
### Version 2.5.
|
|
48
|
-
-
|
|
49
|
-
### Version 2.5.
|
|
50
|
-
-
|
|
51
|
-
### Version 2.5.
|
|
52
|
-
-
|
|
53
|
-
### Version 2.5.
|
|
54
|
-
-
|
|
55
|
-
### Version 2.5.
|
|
56
|
-
-
|
|
57
|
-
### Version 2.
|
|
58
|
-
-
|
|
59
|
-
### Version 2.4.
|
|
60
|
-
-
|
|
61
|
-
### Version 2.
|
|
62
|
-
- Implement
|
|
63
|
-
### Version 2.
|
|
64
|
-
-
|
|
65
|
-
### Version 2.2.
|
|
66
|
-
-
|
|
67
|
-
### Version 2.2.
|
|
68
|
-
-
|
|
69
|
-
### Version 2.2.
|
|
70
|
-
-
|
|
71
|
-
### Version 2.2.
|
|
72
|
-
-
|
|
73
|
-
### Version 2.2.
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
### Version 2.2.
|
|
79
|
-
-
|
|
80
|
-
### Version 2.
|
|
81
|
-
-
|
|
82
|
-
### Version 2.1.
|
|
83
|
-
-
|
|
84
|
-
### Version 2.0
|
|
85
|
-
-
|
|
86
|
-
### Version 2.0.
|
|
87
|
-
- Fix
|
|
88
|
-
### Version 2.0.
|
|
89
|
-
- Fix
|
|
90
|
-
### Version 2.0.
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
- Implement
|
|
96
|
-
### Version 1.
|
|
97
|
-
- Implement
|
|
98
|
-
### Version 1.
|
|
99
|
-
-
|
|
100
|
-
### Version 1.7.
|
|
101
|
-
-
|
|
102
|
-
### Version 1.7.
|
|
103
|
-
-
|
|
104
|
-
### Version 1.7.
|
|
105
|
-
-
|
|
106
|
-
### Version 1.
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
### Version 1.6.
|
|
112
|
-
-
|
|
113
|
-
### Version 1.6.
|
|
114
|
-
- Fix
|
|
115
|
-
### Version 1.6.
|
|
116
|
-
- Fix bug
|
|
117
|
-
### Version 1.6.
|
|
118
|
-
-
|
|
119
|
-
### Version 1.6.
|
|
120
|
-
- Update
|
|
121
|
-
### Version 1.6.
|
|
122
|
-
-
|
|
123
|
-
### Version 1.6.
|
|
124
|
-
-
|
|
125
|
-
### Version 1.6.
|
|
126
|
-
- Minor update normalize
|
|
127
|
-
### Version 1.6
|
|
128
|
-
-
|
|
129
|
-
### Version 1.
|
|
130
|
-
- Add
|
|
131
|
-
### Version 1.5.
|
|
132
|
-
-
|
|
133
|
-
### Version 1.5.
|
|
134
|
-
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
### Version 1.4.
|
|
139
|
-
-
|
|
140
|
-
### Version 1.4.
|
|
141
|
-
- Fix
|
|
142
|
-
### Version 1.4.
|
|
143
|
-
- Fix
|
|
144
|
-
### Version 1.4.
|
|
145
|
-
- Fix minor
|
|
146
|
-
### Version 1.4.
|
|
147
|
-
-
|
|
148
|
-
### Version 1.
|
|
149
|
-
- Implement
|
|
150
|
-
### Version 1.
|
|
151
|
-
- Implement
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
python3 -m pip install --upgrade
|
|
156
|
-
python3 -m
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
1
|
+
# SharedKernel
|
|
2
|
+
this is a shared kernel package
|
|
3
|
+
|
|
4
|
+
# Change Log
|
|
5
|
+
### Version 2.11.3
|
|
6
|
+
- Add S3Uploader.download, which reads an object from S3 using its URL
|
|
7
|
+
### Version 2.11.2
|
|
8
|
+
- Minor fix versioning
|
|
9
|
+
### Version 2.11.1
|
|
10
|
+
- Fix event name field
|
|
11
|
+
### Version 2.11.0
|
|
12
|
+
- Add router name to log service
|
|
13
|
+
### Version 2.10.0
|
|
14
|
+
- implement encryption service
|
|
15
|
+
### Version 2.9.5
|
|
16
|
+
- remove redis fixed version
|
|
17
|
+
### Version 2.9.4
|
|
18
|
+
- fix bug
|
|
19
|
+
### Version 2.9.2
|
|
20
|
+
- add check_access_level to toolbox
|
|
21
|
+
### Version 2.9.1
|
|
22
|
+
- add check_access_level to toolbox
|
|
23
|
+
### Version 2.9.0
|
|
24
|
+
- Add toolbox_service
|
|
25
|
+
### Version 2.8.0
|
|
26
|
+
- Add chunker for tts
|
|
27
|
+
### Version 2.7.0
|
|
28
|
+
- Add Redis and cache repository
|
|
29
|
+
### Version 2.6.4
|
|
30
|
+
- Add Verbose to log
|
|
31
|
+
### Version 2.6.3
|
|
32
|
+
- fix bug ip-header-name
|
|
33
|
+
### Version 2.6.2
|
|
34
|
+
- Add Verbose
|
|
35
|
+
### Version 2.6.1
|
|
36
|
+
- hotfix namings
|
|
37
|
+
### Version 2.6.0
|
|
38
|
+
- add cookie validation to jwt service
|
|
39
|
+
### Version 2.5.9
|
|
40
|
+
- Fix bug
|
|
41
|
+
### Version 2.5.8
|
|
42
|
+
- Add Session Lifetime Update
|
|
43
|
+
### Version 2.5.7
|
|
44
|
+
- Add Database Health Check
|
|
45
|
+
### Version 2.5.6
|
|
46
|
+
- fix bug
|
|
47
|
+
### Version 2.5.5
|
|
48
|
+
- fix bug
|
|
49
|
+
### Version 2.5.4
|
|
50
|
+
- Add Ip Session Service
|
|
51
|
+
### Version 2.5.3
|
|
52
|
+
- Fix bug
|
|
53
|
+
### Version 2.5.2
|
|
54
|
+
- Minor Fix
|
|
55
|
+
### Version 2.5.1
|
|
56
|
+
- Apply log on jwt service
|
|
57
|
+
### Version 2.5.0
|
|
58
|
+
- Implement logger
|
|
59
|
+
### Version 2.4.1
|
|
60
|
+
- Fix file validation
|
|
61
|
+
### Version 2.4.0
|
|
62
|
+
- Implement file validation
|
|
63
|
+
### Version 2.3.0
|
|
64
|
+
- Implement multipart uploader for S3
|
|
65
|
+
### Version 2.2.7
|
|
66
|
+
- add presigned url in s3 uploader
|
|
67
|
+
### Version 2.2.6
|
|
68
|
+
- implement api key
|
|
69
|
+
### Version 2.2.5
|
|
70
|
+
- add org_token to user_info Object
|
|
71
|
+
### Version 2.2.4
|
|
72
|
+
- make pagination response default values to None
|
|
73
|
+
### Version 2.2.3
|
|
74
|
+
- add paginate to mongo repository
|
|
75
|
+
### Version 2.2.2
|
|
76
|
+
- update on audit logging queries
|
|
77
|
+
- added is_audit to update_one parameters
|
|
78
|
+
### Version 2.2.1
|
|
79
|
+
- fixbug requirements
|
|
80
|
+
### Version 2.2.0
|
|
81
|
+
- implement Audit logging
|
|
82
|
+
### Version 2.1.2
|
|
83
|
+
- Update pydantic parse_object with model_validate
|
|
84
|
+
### Version 2.1.0
|
|
85
|
+
- Implement persian string normalizer
|
|
86
|
+
### Version 2.0.3
|
|
87
|
+
- Fix boto3 version
|
|
88
|
+
### Version 2.0.2
|
|
89
|
+
- Fix FastApi dependency
|
|
90
|
+
### Version 2.0.1
|
|
91
|
+
- Fix minor bugs
|
|
92
|
+
### Version 2.0.0
|
|
93
|
+
- Update pydantic version
|
|
94
|
+
- Delete vector databases
|
|
95
|
+
- Implement JsonStringModel
|
|
96
|
+
### Version 1.9.0
|
|
97
|
+
- Implement DataFormatConverter
|
|
98
|
+
### Version 1.8.0
|
|
99
|
+
- Implement persian number normalizer
|
|
100
|
+
### Version 1.7.3
|
|
101
|
+
- Add optional folder name for s3 uploader to save the file in
|
|
102
|
+
### Version 1.7.2
|
|
103
|
+
- Fix bug of to_diff_persian_date_time_string
|
|
104
|
+
### Version 1.7.1
|
|
105
|
+
- Update BaseDocument initial values
|
|
106
|
+
### Version 1.7.0
|
|
107
|
+
- Implement S3 Uploader
|
|
108
|
+
### Version 1.6.10
|
|
109
|
+
- Add updated_on to BaseDocument
|
|
110
|
+
- Update phonenumber normalizer
|
|
111
|
+
### Version 1.6.9
|
|
112
|
+
- Delete milvus
|
|
113
|
+
### Version 1.6.8
|
|
114
|
+
- Fix Date Converter Bug
|
|
115
|
+
### Version 1.6.7
|
|
116
|
+
- Fix bug and remove additional features
|
|
117
|
+
### Version 1.6.6
|
|
118
|
+
- Fix bug of phonenumber normalizer
|
|
119
|
+
### Version 1.6.5
|
|
120
|
+
- Update on the JWTBearer (Save decoded token in request state)
|
|
121
|
+
### Version 1.6.4
|
|
122
|
+
- Update normlizer package
|
|
123
|
+
### Version 1.6.3
|
|
124
|
+
- Fix minor bug in phone normalizer
|
|
125
|
+
### Version 1.6.2
|
|
126
|
+
- Minor update: normalize function name
|
|
127
|
+
### Version 1.6.1
|
|
128
|
+
- Minor update normalize functions
|
|
129
|
+
### Version 1.6
|
|
130
|
+
- Add phone number normalizer
|
|
131
|
+
### Version 1.5.2
|
|
132
|
+
- Add created_on to base_document
|
|
133
|
+
### Version 1.5.1
|
|
134
|
+
- fix mongo repository bug
|
|
135
|
+
### Version 1.5.0
|
|
136
|
+
- implement date converter
|
|
137
|
+
- example: فردا - دیروز - یک ماه قبل
|
|
138
|
+
### Version 1.4.5
|
|
139
|
+
- upgrade fastapi version
|
|
140
|
+
### Version 1.4.4
|
|
141
|
+
- Fix regex masking bugs
|
|
142
|
+
### Version 1.4.3
|
|
143
|
+
- Fix collection bug in MongoGenericRepository
|
|
144
|
+
### Version 1.4.2
|
|
145
|
+
- Fix minor bugs
|
|
146
|
+
### Version 1.4.1
|
|
147
|
+
- Fix minor bug in MongoGenericRepository
|
|
148
|
+
### Version 1.4.0
|
|
149
|
+
- Implement date convertor for jalali and georgian
|
|
150
|
+
### Version 1.3.0
|
|
151
|
+
- Implement Sentry For Log Exceptions
|
|
152
|
+
### Version 1.2.0
|
|
153
|
+
- Implement Regex Masking
|
|
154
|
+
# Create Package
|
|
155
|
+
python3 -m pip install --upgrade build
|
|
156
|
+
python3 -m build
|
|
157
|
+
python3 -m pip install --upgrade twine
|
|
158
|
+
python3 -m twine upload dist/*
|
|
159
|
+
|
|
160
|
+
# Pypi
|
|
161
|
+
pip install sharedkernel
|
|
@@ -44,7 +44,7 @@ setup(
|
|
|
44
44
|
"cryptography",
|
|
45
45
|
],
|
|
46
46
|
# *strongly* suggested for sharing
|
|
47
|
-
version="2.11.
|
|
47
|
+
version="2.11.3",
|
|
48
48
|
description="sharekernel is a shared package between all python projects",
|
|
49
49
|
long_description=long_description,
|
|
50
50
|
long_description_content_type="text/markdown",
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
import requests
|
|
3
|
-
import boto3
|
|
4
|
-
from io import BytesIO
|
|
5
|
-
import uuid
|
|
6
2
|
import os
|
|
3
|
+
import uuid
|
|
4
|
+
from io import BytesIO
|
|
5
|
+
from typing import BinaryIO
|
|
6
|
+
from urllib.parse import unquote, urlparse
|
|
7
|
+
|
|
8
|
+
import boto3
|
|
9
|
+
import requests
|
|
10
|
+
|
|
7
11
|
from sharedkernel.multipart_upload import MultipartUploadSession
|
|
8
12
|
|
|
13
|
+
|
|
9
14
|
class S3Uploader:
|
|
10
|
-
def __init__(self, endpoint_url, bucket, access_key, secret_key):
|
|
15
|
+
def __init__(self, endpoint_url: str, bucket: str, access_key: str, secret_key: str) -> None:
|
|
11
16
|
self.endpoint_url = endpoint_url
|
|
12
17
|
self.bucket = bucket
|
|
13
18
|
self.access_key = access_key
|
|
@@ -21,7 +26,11 @@ class S3Uploader:
|
|
|
21
26
|
)
|
|
22
27
|
|
|
23
28
|
@staticmethod
|
|
24
|
-
def __generate_object_name(
|
|
29
|
+
def __generate_object_name(
|
|
30
|
+
object_name: str | None = None,
|
|
31
|
+
file_extension: str | None = None,
|
|
32
|
+
folder_name: str | None = None,
|
|
33
|
+
) -> str:
|
|
25
34
|
if object_name is None:
|
|
26
35
|
object_name = str(uuid.uuid4())
|
|
27
36
|
|
|
@@ -34,7 +43,14 @@ class S3Uploader:
|
|
|
34
43
|
return object_name
|
|
35
44
|
|
|
36
45
|
|
|
37
|
-
def upload_file_object(
|
|
46
|
+
def upload_file_object(
|
|
47
|
+
self,
|
|
48
|
+
file_obj: BinaryIO,
|
|
49
|
+
object_name: str | None = None,
|
|
50
|
+
file_extension: str | None = None,
|
|
51
|
+
folder_name: str | None = None,
|
|
52
|
+
public_read: bool = True,
|
|
53
|
+
) -> str:
|
|
38
54
|
object_name = self.__generate_object_name(object_name, file_extension, folder_name)
|
|
39
55
|
|
|
40
56
|
acl = "public-read" if public_read else "private"
|
|
@@ -45,7 +61,13 @@ class S3Uploader:
|
|
|
45
61
|
|
|
46
62
|
return file_url
|
|
47
63
|
|
|
48
|
-
def generate_presigned_url(
|
|
64
|
+
def generate_presigned_url(
|
|
65
|
+
self,
|
|
66
|
+
object_name: str | None = None,
|
|
67
|
+
file_extension: str | None = None,
|
|
68
|
+
folder_name: str | None = None,
|
|
69
|
+
expire_time: int = 3600,
|
|
70
|
+
) -> str:
|
|
49
71
|
object_name = self.__generate_object_name(object_name, file_extension, folder_name)
|
|
50
72
|
|
|
51
73
|
temp_url = self.s3.generate_presigned_url(
|
|
@@ -58,8 +80,27 @@ class S3Uploader:
|
|
|
58
80
|
)
|
|
59
81
|
|
|
60
82
|
return temp_url
|
|
61
|
-
|
|
62
|
-
def
|
|
83
|
+
|
|
84
|
+
def download(self, file_url: str) -> bytes:
|
|
85
|
+
"""Downloads a file by parsing its URL and reading that object from S3."""
|
|
86
|
+
object_name = self.__object_name_from_url(file_url)
|
|
87
|
+
response = self.s3.get_object(Bucket=self.bucket, Key=object_name)
|
|
88
|
+
return response["Body"].read()
|
|
89
|
+
|
|
90
|
+
def __object_name_from_url(self, file_url: str) -> str:
|
|
91
|
+
parsed = urlparse(file_url)
|
|
92
|
+
path = unquote(parsed.path).lstrip("/")
|
|
93
|
+
bucket_prefix = "{}/".format(self.bucket)
|
|
94
|
+
if path.startswith(bucket_prefix):
|
|
95
|
+
return path[len(bucket_prefix):]
|
|
96
|
+
return path
|
|
97
|
+
|
|
98
|
+
def upload_file_from_url(
|
|
99
|
+
self,
|
|
100
|
+
file_url: str,
|
|
101
|
+
object_name: str | None = None,
|
|
102
|
+
folder_name: str | None = None,
|
|
103
|
+
) -> str:
|
|
63
104
|
"""
|
|
64
105
|
Downloads a file from a URL and uploads it to an S3 bucket, returning its URL.
|
|
65
106
|
|
|
@@ -85,11 +126,11 @@ class S3Uploader:
|
|
|
85
126
|
|
|
86
127
|
def create_multipart_session(
|
|
87
128
|
self,
|
|
88
|
-
object_name=None,
|
|
89
|
-
file_extension=None,
|
|
90
|
-
folder_name=None,
|
|
91
|
-
public_read=True,
|
|
92
|
-
):
|
|
129
|
+
object_name: str | None = None,
|
|
130
|
+
file_extension: str | None = None,
|
|
131
|
+
folder_name: str | None = None,
|
|
132
|
+
public_read: bool = True,
|
|
133
|
+
) -> MultipartUploadSession:
|
|
93
134
|
object_key = self.__generate_object_name(
|
|
94
135
|
object_name, file_extension, folder_name
|
|
95
136
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sharedkernel
|
|
3
|
-
Version: 2.11.
|
|
3
|
+
Version: 2.11.3
|
|
4
4
|
Summary: sharekernel is a shared package between all python projects
|
|
5
5
|
Author: Smilinno
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -33,6 +33,8 @@ Dynamic: summary
|
|
|
33
33
|
this is a shared kernel package
|
|
34
34
|
|
|
35
35
|
# Change Log
|
|
36
|
+
### Version 2.11.3
|
|
37
|
+
- Add S3Uploader.download, which reads an object from S3 using its URL
|
|
36
38
|
### Version 2.11.2
|
|
37
39
|
- Minor fix versioning
|
|
38
40
|
### Version 2.11.1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/cache/redis_generic_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
{sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/mongo_generic_audit_repository.py
RENAMED
|
File without changes
|
{sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/mongo_generic_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
{sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/database/pagination_response_dto.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sharedkernel-2.11.2 → sharedkernel-2.11.3}/sharedkernel/normalizer/phone_number_normalizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|