Skip to content

diananareiko/backgroundUpload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Background Upload in iOS 🚀


Overview

This repository demonstrates how to implement background uploads in iOS applications using SwiftUI and the URLSession API with a .background configuration. The app allows you to upload images to imgBB while running code in the background, even when the app is suspended Or terminated (in case your app is terminated, you can send a silent push to wake it up and then call a method that requests the service to continue uploading).


Features

  • SwiftUI Integration: Modern UI designed using SwiftUI.
  • Background Upload: Uploads files using URLSession with .background configuration.
  • imgBB API Integration: Utilizes the imgBB API for uploading and managing image files.
  • Error Handling: Handles upload errors and provides success/error feedback.

API Used: imgBB

To upload images, the project uses the imgBB API. This REST API allows you to upload images and retrieve their URLs up to 32 MB free.

API Key Requirement

Before running the project, you must obtain an API key from imgBB:

  1. Visit the imgBB API Key Page.
  2. Create an account (if you don’t already have one).
  3. Generate an API key.

Getting Started

Step 1: Clone the Repository

git clone https://github.com/diananareiko/backgroundUpload.git
cd your-repo-name

Step 2: Add Your API Key

  1. Open the project in Xcode.
  2. Navigate to Info.plist.
  3. Fill in IMGBB_API_KEY

Step 3: Build and Run

  • Open the project in Xcode.
  • Select a real device as the build target (simulators don’t support background uploads effectively).
  • Build and run the app.

How It Works

1. Uploading Images

The app enables users to upload images to imgBB. The upload process runs in the background, allowing it to continue even if the app is suspended.

2. Background Upload with URLSession

  • A URLSession instance with a .background configuration handles file uploads.
  • The app saves the image data as a temporary file and uploads it to the imgBB API using uploadTask.

Technology Stack

  • SwiftUI: For building the app's user interface.
  • URLSession: For managing background upload tasks.
  • imgBB API: For handling image uploads.
  • Xcode: For iOS app development.

Screenshots

Photo 1 Photo 2 Photo 3
Screenshot 1 Screenshot 2 Screenshot 3

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes and submit a pull request.

Useful Resources


Developed By

Diana Nareiko
Email: diananareiko8@gmail.com
GitHub: https://github.com/diananareiko


About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages