MCPcopy
hub / github.com/diffgram/diffgram / upload

Method upload

shared/instance_tools.py:106–127  ·  view source on GitHub ↗
(self, session, instance, cropped_image)

Source from the content-addressed store, hash-verified

104 return resized_cropped_image
105
106 def upload(self, session, instance, cropped_image):
107
108 # We may want to save this to the instance
109 # as well, but I think it would reduce other issues if we saved
110 # it to the sequence instead?
111
112 image_out_filename = f"{self.temp}image_out.jpg"
113 imwrite(image_out_filename, cropped_image)
114
115 instance.preview_image_blob_dir = f"{settings.PROJECT_INSTANCES_IMAGES_BASE_DIR + str(instance.id)}/_thumb.jpg"
116
117 data_tools.upload_to_cloud_storage(
118 temp_local_path = image_out_filename,
119 blob_path = instance.preview_image_blob_dir,
120 content_type = 'image/jpg'
121 )
122
123 instance.preview_image_url = data_tools.build_secure_url(
124 blob_name = instance.preview_image_blob_dir,
125 expiration_offset = 2592000
126 )
127 session.add(instance)

Callers 1

Calls 3

build_secure_urlMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected