Skip to content

Google-Developers-Group-IIIT-Lucknow/DevSphere-App-iOS-Hard

Repository files navigation

☁️ DevSphere iOS — File Upload App (Hard)

A native iOS application built with Swift & SwiftUI that lets users pick any file from their device and upload it to the cloud via the Cloudinary API.


📸 Preview

┌──────────────────────────┐
│   📂  Select a File      │
│                          │
│   FileName.pdf           │
│   Status: Uploading...   │
│                          │
│   [ Upload to Cloud ]    │
│                          │
│   ✅ https://res.cloud.. │
└──────────────────────────┘

🗂️ Project Structure

DevSphere-App-iOS-Hard/
├── Config/
│   └── CloudinaryConfig.plist       # 🔑 Add your cloud name & upload preset here
├── Views/
│   └── ContentView.swift            # 🖼️ Main SwiftUI UI
├── Logic/
│   ├── FilePickerLogic.swift        # 📂 File selection handler
│   └── CloudinaryUploader.swift     # ☁️ Upload function
└── README.md

🚀 Getting Started

1️⃣ Fork & Clone the Repository

git clone https://github.com/Google-Developers-Group-IIIT-Lucknow/DevSphere-App-iOS-Hard.git
cd DevSphere-App-iOS-Hard

2️⃣ Open in Xcode

  1. Open Xcode
  2. Click Open a Project or File
  3. Select the cloned folder
  4. Wait for Swift Package Manager to resolve dependencies

3️⃣ Create a Cloudinary Account

  1. Go to cloudinary.com and sign up (free tier is enough)
  2. From your Dashboard, copy your Cloud Name
  3. Go to Settings → Upload → Upload Presets
  4. Create an unsigned upload preset and copy its name

🔧 Configuration

Open Config/CloudinaryConfig.plist and replace the placeholder values:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CLOUDINARY_CLOUD_NAME</key>
    <string>your_cloud_name</string>        <!-- ✏️ Replace this -->
    <key>CLOUDINARY_UPLOAD_PRESET</key>
    <string>your_upload_preset</string>     <!-- ✏️ Replace this -->
</dict>
</plist>

⚠️ Do NOT commit real credentials to a public repository. Add CloudinaryConfig.plist to .gitignore or use environment variables for production.


🧑‍💻 What You Need to Implement

1. 📂 File Picker Logic — FilePickerLogic.swift

Handle the result of the document picker:

Requirements:

  • ✅ Handle empty/cancelled selection gracefully
  • ✅ Store fileName and fileURL in state
  • ✅ Update status label after selection

🌐 Cloudinary API Reference

Property Value
Endpoint https://api.cloudinary.com/v1_1/{cloud_name}/auto/upload
Method POST
Body Type multipart/form-data
Required Fields upload_preset, file
Response Key secure_url — the public URL of the uploaded file

✅ Requirements Checklist

Feature Description
☐ File Selection Works via UIDocumentPickerViewController for any file type
☐ Security Scoped Resources Proper startAccessingSecurityScopedResource / defer usage
☐ Multipart Request Correctly structured multipart/form-data body
☐ API Call POST to Cloudinary endpoint using URLSession
☐ Response Parsing Extracts secure_url from JSON response
☐ Status Messages Shows Uploading…, ✅ Success, or ❌ Error in the UI
☐ Error Handling Handles file read errors, network errors, and bad responses
☐ No Crashes App handles nil/invalid input without crashing

🧪 Testing Your Implementation

  1. Run the app on a real device or simulator
  2. Tap Select File → choose any file (PDF, image, text, etc.)
  3. Tap Upload to Cloud
  4. Verify:
    • Status changes to Uploading...
    • On success, a https://res.cloudinary.com/... URL appears
    • Log into your Cloudinary dashboard to confirm the file is there

📌 Notes

  • Use an unsigned upload preset for this project (no API secret needed)
  • The /auto/upload endpoint automatically detects file type
  • secure_url in the response always uses HTTPS
  • Security-scoped resources must be released with stopAccessingSecurityScopedResource()

🤝 Contributing

  1. Fork the repo
  2. Create your branch: git checkout -b feature/your-feature
  3. Commit changes: git commit -m "feat: add your feature"
  4. Push: git push origin feature/your-feature
  5. Open a Pull Request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors