MCPcopy
hub / github.com/diffgram/diffgram / build_secure_url

Method build_secure_url

shared/data_tools_core_s3.py:240–266  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

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 """

Callers 15

process_profile_imageFunction · 0.45
process_image_genericFunction · 0.45
upload_video_fileMethod · 0.45
save_text_tokensMethod · 0.45
save_raw_audio_fileMethod · 0.45
save_raw_text_fileMethod · 0.45
uploadMethod · 0.45
default_url_regenerateFunction · 0.45
get_profile_image_urlMethod · 0.45

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected