Regenerates signed URL using blob default storage provider from DataTools(). :param session: :param blob_object: :param new_offset_in_seconds: :return:
(session: Session,
blob_object: DiffgramBlobObjectType,
new_offset_in_seconds: int)
| 40 | |
| 41 | |
| 42 | def default_url_regenerate(session: Session, |
| 43 | blob_object: DiffgramBlobObjectType, |
| 44 | new_offset_in_seconds: int) -> [DiffgramBlobObjectType, dict]: |
| 45 | """ |
| 46 | Regenerates signed URL using blob default storage provider from DataTools(). |
| 47 | :param session: |
| 48 | :param blob_object: |
| 49 | :param new_offset_in_seconds: |
| 50 | :return: |
| 51 | """ |
| 52 | log = regular_log.default() |
| 53 | try: |
| 54 | blob_object.url_signed = data_tools.build_secure_url(blob_object.url_signed_blob_path, new_offset_in_seconds) |
| 55 | blob_object.url_signed_expiry = time.time() + new_offset_in_seconds |
| 56 | if type(blob_object) == Image and blob_object.url_signed_thumb_blob_path: |
| 57 | blob_object.url_signed_thumb = data_tools.build_secure_url(blob_object.url_signed_thumb_blob_path, |
| 58 | new_offset_in_seconds) |
| 59 | session.add(blob_object) |
| 60 | |
| 61 | # Extra assets (Depending on type) |
| 62 | if type(blob_object) == Image and blob_object.url_signed_thumb_blob_path: |
| 63 | blob_object.url_signed_thumb = data_tools.build_secure_url(blob_object.url_signed_thumb_blob_path, |
| 64 | new_offset_in_seconds) |
| 65 | if type(blob_object) == TextFile and blob_object.tokens_url_signed_blob_path: |
| 66 | blob_object.tokens_url_signed = data_tools.build_secure_url(blob_object.tokens_url_signed_blob_path, |
| 67 | new_offset_in_seconds) |
| 68 | |
| 69 | except Exception as e: |
| 70 | msg = traceback.format_exc() |
| 71 | logger.error(msg) |
| 72 | if type(blob_object) == Image: |
| 73 | blob_object.error = msg |
| 74 | log['error']['default_url_regenerate'] = msg |
| 75 | return blob_object, log |
| 76 | return blob_object, log |
| 77 | |
| 78 | |
| 79 |
no test coverage detected