@@ -1197,25 +1197,29 @@ def mutate(self, info, user_id):
11971197
11981198 if int (get_jwt_identity ()) != user_id :
11991199 raise GraphQLError ("Unauthorized operation" )
1200-
1201- s3 = boto3 .client (
1202- "s3" ,
1203- endpoint_url = os .getenv ("DIGITAL_OCEAN_URL" ),
1204- aws_access_key_id = os .getenv ("DIGITAL_OCEAN_ACCESS" ),
1205- aws_secret_access_key = os .getenv ("DIGITAL_OCEAN_SECRET_ACCESS" ),
1206- config = Config (s3 = {"addressing_style" : "path" }),
1207- )
1208-
1200+
1201+ logging .info (f"DIGITAL_OCEAN_URL: { os .getenv ('DIGITAL_OCEAN_URL' )} " )
1202+ logging .info (f"User encoded_image: { user .encoded_image } " )
1203+
12091204 if user .encoded_image :
12101205 try :
1206+ logging .info ("Attempting S3 delete..." )
1207+ s3 = boto3 .client (
1208+ "s3" ,
1209+ endpoint_url = os .getenv ("DIGITAL_OCEAN_URL" ),
1210+ aws_access_key_id = os .getenv ("DIGITAL_OCEAN_ACCESS" ),
1211+ aws_secret_access_key = os .getenv ("DIGITAL_OCEAN_SECRET_ACCESS" ),
1212+ config = Config (s3 = {"addressing_style" : "path" }),
1213+ )
12111214 s3 .delete_object (
12121215 Bucket = "appdev-upload" ,
1213- Key = f"uplift-dev/user-profile/{ user .net_id } -profile.png" ,
1216+ Key = f"uplift-dev/user-profile/{ user .net_id } -profile.png" ,
12141217 )
1218+ logging .info ("S3 delete succeeded" )
12151219 except Exception as e :
1216- print ( "Delete error:" , e )
1217- raise GraphQLError ("Error deleting user profile picture " )
1218-
1220+ logging . error ( f"S3 delete failed: { type ( e ). __name__ } : { e } " )
1221+ raise GraphQLError (f"S3 error: { type ( e ). __name__ } : { e } " )
1222+
12191223 db_session .delete (user )
12201224 db_session .commit ()
12211225 return user
0 commit comments