Builds a presigned URL to access the given blob path. :param blob_name: The path to the blob for the presigned URL :param expiration_offset: The expiration time for the presigned URL :param bucket: string for the bucket type (either 'web' or 'ml') defaults to 'we
(self, blob_name: str, expiration_offset: int = None, bucket: str = "web")
| 238 | return image_np |
| 239 | |
| 240 | def build_secure_url(self, blob_name: str, expiration_offset: int = None, bucket: str = "web"): |
| 241 | """ |
| 242 | Builds a presigned URL to access the given blob path. |
| 243 | :param blob_name: The path to the blob for the presigned URL |
| 244 | :param expiration_offset: The expiration time for the presigned URL |
| 245 | :param bucket: string for the bucket type (either 'web' or 'ml') defaults to 'web' |
| 246 | :return: the string for the presigned url |
| 247 | """ |
| 248 | if expiration_offset is None: |
| 249 | expiration_offset = settings.SIGNED_URL_CACHE_NEW_OFFSET_SECONDS_VALID |
| 250 | |
| 251 | |
| 252 | if bucket == "web": |
| 253 | bucket_name = self.s3_bucket_name |
| 254 | |
| 255 | if bucket == "ml": |
| 256 | bucket_name = self.s3_bucket_name_ml |
| 257 | |
| 258 | filename = blob_name.split("/")[-1] |
| 259 | |
| 260 | signed_url = self.s3_client.generate_presigned_url('get_object', |
| 261 | Params = { |
| 262 | 'Bucket': bucket_name, |
| 263 | 'ResponseContentDisposition': f"attachment; filename={filename}", |
| 264 | 'Key': blob_name}, |
| 265 | ExpiresIn = int(expiration_offset)) |
| 266 | return signed_url |
| 267 | |
| 268 | def get_string_from_blob(self, blob_name: str): |
| 269 | """ |
no test coverage detected