Skip to content

oliwonders/AzureStorageSwift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

108 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AzureStorageSwift

A Swift Package for Azure Storage access on macOS & iOS, providing simple and efficient Blob container interactions.

Example on how to use: AzureBlobCLI.

Note: This package is forked from the deprecated Azure Storage iOS SDK. While it is funcitonal, there is some risk of Microsoft breaking it. The offically maintained package can be found here -> Azure SDK for iOS.

Motivation

Microsoft’s iOS (macOS) SDK doesn’t yet ship a standalone blob client via SPM. This just makes it simplier to integrate. This library is a stop‑gap until the official AzureStorageBlob package lands Here.

Of course, REST is an option, I prefer having a non-rest api.

Features

  • Basic Blob container operations (upload, download, delete)
  • Support for both macOS and iOS platforms
  • Simple integration via Swift Package Manager

Prerequisites

Installation

Swift Package Manager

  1. Open your Xcode project
  2. Navigate to File → Add Package Dependencies
  3. Enter the repository URL:
    https://github.com/oliwonders/AzureStorageSwift.git
    
  4. Click Add Package

Basic Usage

    let sasUrl = "https://yourstorageaccount.blob.core.windows.net/containername?sv=2020-08-04&ss=b&srt=co&sp=rwdlacitfx&se=2023-04-30T17:31:42Z&st=2023-04-30T09:31:42Z&spr=https&sig=XXXXX"

    let container = try AZSCloudBlobContainer(url: URL(string: sasUrl))

    // List blobs in the container
    container.listBlobsSegmented(
        with: nil,
        prefix: nil,
        useFlatBlobListing: true,
        blobListingDetails: AZSBlobListingDetails(),
        maxResults: 50
    ) { (error, results) in
        if let error = error {
            print("Error listing blobs: \(error.localizedDescription)")
            return
        }

        guard let blobs = results?.blobs as? [AZSCloudBlob] else {
            print("No blobs found or unable to cast results")
            return
        }

        print("Found \(blobs.count) blobs:")
        for blob in blobs {
            print("- \(blob.blobName ?? "Unknown")")
        }
    }

Note for Command-Line Applications: Azure Storage operations are asynchronous. In command-line tools, you may need to use a DispatchGroup or RunLoop to prevent the program from exiting before operations complete.

Known Limitations

  • Limited to basic Blob storage operations
  • No support for advanced Azure Storage features
  • May not receive regular security updates due to being based on deprecated SDK

Support

Contributing

Contributions are welcome! Fork and create a PR.

About

Swift package for accessing Azure Storage from macOS and iOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Objective-C 99.4%
  • Swift 0.6%