services.cloudstore#

Module Contents#

Classes#

CloudService

Class for handling image and file uploads to Cloudinary.

API#

class services.cloudstore.CloudService#

Class for handling image and file uploads to Cloudinary.

async static upload_picture(user_id: int, image_file: fastapi.UploadFile, folder_name: str = None)#

Upload an original image to Cloudinary.

Parameters:
  • user_id (int) – User ID associated with the image.

  • image_file (UploadFile) – UploadFile object representing the image file.

  • folder_name (str) – Optional folder name for organizing images.

Returns:

Tuple containing the URL and public ID of the uploaded image.

Return type:

tuple

async static upload_transformed_picture(user_id: int, image_url: str, transformation_params: dict)#

Upload a transformed image to Cloudinary.

Parameters:
  • user_id (int) – User ID associated with the image.

  • image_url (str) – URL of the image to be transformed.

  • transformation_params (dict) – Dictionary of transformation parameters.

Returns:

Tuple containing the URL and public ID of the uploaded transformed image.

Return type:

tuple

async static delete_picture(public_id: str)#

Delete an image from Cloudinary.

Parameters:

public_id (str) – Public ID of the image to be deleted.

Raises:

HTTPException – If an error occurs while deleting the image.

async static upload_qr_code(user_id: int, img: PIL.Image.Image)#

Upload a QR code image to Cloudinary.

Parameters:
  • user_id (int) – User ID associated with the QR code.

  • img (Image.Image) – PIL Image object representing the QR code.

Returns:

Tuple containing the URL and public ID of the uploaded QR code.

Return type:

tuple

async static update_picture_on_cloudinary(public_id: str, transformation_params: dict)#

Update an image on Cloudinary with specified transformations.

Parameters:
  • public_id (str) – Public ID of the image to be updated.

  • transformation_params (dict) – Dictionary of transformation parameters.

Returns:

URL of the updated image.

Return type:

str