ICS 214: IT WORKSHOP III Project

SkyDrive

Dara Singh 2023BCY0045
Akshat Saraswat 2023BCY0048
Sanjay Sahu 2023BCY0051
Akhil Yadav 2023BCY0054
Nahil Rasheed K.E 2023BCY0057
Abraham Thomas 2023BCY0060
Varshith Reddy 2023BCY0063

Project Overview

Design and implement a cloud storage solution that allows users to upload, download and share files.

Key Features

  • File upload/download
  • File sharing
  • Preview generation
  • Search functionality

Technical Architecture

Architecture Diagram
  • User can upload, download and share files using the web interface
  • Client communicates with the server using REST APIs
  • Server interacts with the database to store and retrieve files
  • Server generates previews for images and PDFs

Key Technical Components

  • File Processing System
  • Preview generation for images and PDFs
  • File format support
  • Security Implementation
    • Access control
    • File permissions

Code Highlights

Sending Emails on User Registration

import resend
params: resend.Emails.SendParams = {
	from: "[email protected]",
	to: [user.email],
	template_id: "d-1f"
}
resend.Emails.send(params)
			
			

Logging in

@router.post("/api/auth/login")
async def login(user: UserLogin):
	response = supabase.auth.sign_in_with_password(
		{"email": user.email, "password": user.password}
	)

	if response.user is None:
		raise HTTPException(status_code=400, detail="Login failed")

	token = secrets.token_urlsafe(32)
	redis_instance.set(token, response.user.id)
	login_response = {
		"message": "Login successful",
		"token": token
	}
	return login_response
				
			

Listing Files

from pydantic import BaseModel
@router.post("/api/files")
async def get_user_files(req: GetFiles, userid=Depends(get_current_user)):
	class File(BaseModel):
		fileId: str
		fileName: str
		previewImage: str

	data = supabase_admin.table("files").select("*").eq("owner", userid).execute()
	files: List[File] = []

	if data.data is not None:
		for db_file in data.data:
			file = File(
				fileId=db_file["id"],
				fileName=db_file["filename"],
				previewImage=db_file["preview_image"],
			)
			files.append(file)

	return {"message": "Files retrieved successfully", "files": files}
			
			

Sharing Files

@router.patch("/api/files/{fileId}/share")
async def share_file(fileId: str, req: reqBody, userid=Depends(get_current_user)):
	# Check file ownership
	file_query = (
		supabase_admin.table("files").select("owner").eq("id", fileId).execute()
	)
	if file_query.data[0]["owner"] != userid:
		return {"message": "You are not the owner of this file"}

	# Update file and create sharing record
	supabase_admin.table("files").update({"is_shared": True}).eq(
		"id", fileId
	).execute()
	supabase_admin.table("shared").insert(
		{"file_id": fileId, "shared_with": recipient_id}
	).execute()

	return {"message": "File shared successfully"}
				
			

Engineering Challenges

  • PDF preview generation
  • Image processing optimization
  • Access control implementation
  • Performance considerations

Future Improvements

  • Additional file format support
  • Enhanced sharing features