Giter Club home page Giter Club logo

azure-storage-ios's Introduction

Azure Storage Client Library for iOS (Deprecated)

This project is not being actively maintained. Once a replacement is released, the link will be published here.

Overview

This library is designed to help you build iOS applications that use Microsoft Azure Storage. At the moment, the library is in a preview stage, so thank you for taking a look! It will be some time before the library is stable. In the meantime, we would like to get as much input as possible from the community. Please let us know of any issues you encounter by opening an issue on Github.

The library currently supports almost all blob operations (some exceptions noted below.) Other services (table, queue, file) are forthcoming, depending on demand.

To use this library, you need the following:

  • iOS 8+
  • Xcode 7+

How to get started

The recommended way to use the library is through a Cocoapod, available here. Reference documention is available here.

Podfile

platform :ios, '8.0'

target 'TargetName' do
  pod 'AZSClient'
end

Framework

The other way to use the library is to build the framework manually:

  1. First, download or clone the azure-storage-ios repo.
  2. Go into azure-storage-ios -> Lib -> Azure Storage Client Library, and open AZSClient.xcodeproj in Xcode.
  3. At the top-left of Xcode, change the active scheme from "Azure Storage Client Library" to "Framework".
  4. Build the project (⌘+B). This will create an AZSClient.framework file on your Desktop.

You can then import the framework file into your application by doing the following:

  1. Create a new project or open up your existing project in Xcode.
  2. Drag and drop the AZSClient.framework into your Xcode project navigator.
  3. Select Copy items if needed, and click on Finish.
  4. Click on your project in the left-hand navigation and click the General tab at the top of the project editor.
  5. Under the Linked Frameworks and Libraries section, click the Add button (+).
  6. In the list of libraries already provided, search for libxml2.2.tbd and add it to your project.

Import statement

#import <AZSClient/AZSClient.h>

If you are using Swift, you will need to create a bridging header and import <AZSClient/AZSClient.h> there:

  1. Create a header file Bridging-Header.h, and add the above import statement.
  2. Go to the Build Settings tab, and search for Objective-C Bridging Header.
  3. Double-click on the field of Objective-C Bridging Header and add the path to your header file: ProjectName/Bridging-Header.h
  4. Build the project (⌘+B) to verify that the bridging header was picked up by Xcode.
  5. Start using the library directly in any Swift file, there is no need for import statements.

Here is a small code sample that creates and deletes a blob:

-(void)createAndDeleteBlob
{
    // Create a semaphore to prevent the method from exiting before all of the async operations finish.
    // In most real applications, you wouldn't do this, it makes this whole series of operations synchronous.
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    
    // Create a storage account object from a connection string.
    AZSCloudStorageAccount *account = [AZSCloudStorageAccount accountFromConnectionString:@"myConnectionString"];
    
    // Create a blob service client object.
    AZSCloudBlobClient *blobClient = [account getBlobClient];
    
    // Create a local container object with a unique name.
    NSString *containerName = [[NSString stringWithFormat:@"sampleioscontainer%@",[[[NSUUID UUID] UUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""]] lowercaseString];
    AZSCloudBlobContainer *blobContainer = [blobClient containerReferenceFromName:containerName];
    
    // Create the container on the service and check to see if there was an error.
    [blobContainer createContainerWithCompletionHandler:^(NSError* error){
        if (error != nil){
            NSLog(@"Error in creating container.");
        }
        
        // Create a local blob object
        AZSCloudBlockBlob *blockBlob = [blobContainer blockBlobReferenceFromName:@"blockBlob"];
        
        // Get some sample text for the blob
        NSString *blobText = @"Sample blob text";
        
        // Upload the text to the blob.
        [blockBlob uploadFromText:blobText completionHandler:^(NSError *error) {
            if (error != nil){
                NSLog(@"Error in uploading blob.");
            }
            
            // Download the blob's contents to a new text string.
            [blockBlob downloadToTextWithCompletionHandler:^(NSError *error, NSString *resultText) {
                if (error != nil){
                    NSLog(@"Error in downloading blob.");
                }
                
                // Validate that the uploaded/downloaded string is correct.
                if (![blobText isEqualToString:resultText])
                {
                    NSLog(@"Error - the text in the blob does not match.");
                }
                
                // Delete the container from the service.
                [blobContainer deleteContainerWithCompletionHandler:^(NSError* error){
                    if (error != nil){
                        NSLog(@"Error in deleting container.");
                    }
                    
                    dispatch_semaphore_signal(semaphore);
                }];
            }];
        }];
    }];
    
    // Pause the method until the above operations complete.
    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
}

In general, all methods in the Storage Client that make service calls are asynchronous, roughly in the style of NSURLSession. When you call methods on the Storage Client that interact with the Storage Service, you need to pass in a completion handler block to handle the results of the operation. Service calls will return before the operation is complete.

More detailed examples can be found in the test code; better samples are coming soon. Also coming soon: API docs, a getting-started guide, and a downloadable framework file. This page will be updated with the relevant links when they're available.

Functionality

  • Create/List/Delete/Lease Containers.
  • Create/List/Read/Update/Delete/Lease/StartAsyncCopy Blobs.
    • Read/Write from/to Blobs with an NSStream, NSString, NSData, or local file.
    • Operations for specific blob types (block operations for block blobs, etc.)
  • Container and Blob properties and metadata.
  • Get/Set Service Properties (properties for Storage Analytics and CORS rules).
  • Blob virtual directories.
  • Use Shared Key authentication or SAS authentication.
  • Access conditions, automatic retries and retry policies, and logging.

Missing functionality

The following functionality is all coming soon:

  • If you want to download a blob's contents to a stream, this is possible using the DownloadToStream method on AZSCloudBlob. However, it is not yet possible to open an input stream that reads directly from the blob.
  • There are a number of internal details that will change in the upcoming releases. If you look at the internals of the library (or fork it), be prepared. Much of this will be clean-up related.

Specific areas we would like feedback on:

  • NSOperation support. We have had requests to use NSOperation as the primary method of using the library - methods such as 'UploadFromText' would return an NSOperation, that could then be scheduled in an operation queue. However, this approach seems to have several drawbacks, notably along the lines of error handling and data return. (For example, imagine trying to implement a 'CreateIfNotExists' method, using 'Exists' and 'Create'. If they both returned an NSOperation, you could have the 'Create' operation depend on the 'Exists' operation, but the 'Create' operation would need to behave differently in the case that 'Exists' returns an error, or that the resource already exists.) If you have suggestions, please discuss in the wiki, or open an issue.
  • The Azure Storage client currently uses NSURLSession behind the scenes to perform the HTTP requests. Currently, the client does not expose the delegate queue or various session configuration options to users, other than what will be exposed in the RequestOptions object. Is this something you would like to have control over?

Logging

If you are having problems with the library, turning on logging may help. Some notes:

  • All logging is done through the AZSOperationContext. You can either set a global logger (static on the AZSOperationContext class), and/or set a logger on a per-AZSOperationContext basis (both the global and instance loggers will be logged to, if available.) The library supports ASL logging by default, just pass an aslclient into either setGlobalLogger: or setLogger:withCondition:. You can also define your own logging function, with setLogFunction: and setGlobalLogFunction:. This will call into the input block, allowing you to log however you like.
  • Note that the library is multi-threaded. If you use the global ASL logger, this is handled properly for you by the library. If you use setLogger:withCondition:, the library will lock on the input condition before logging to the given logger. It's important to associate loggers with the correct NSCondition objects when setting them, otherwise the single-threaded requirement of the aslclient will not be met. If you pass in your own logging function(s), you should expect that they will be called in a multithreaded context, and you will need to take care of any required locking yourself.
  • You will need to set a minimum log level on either the global or instance logger. AZSLogLevelInfo should be sufficient for almost every scenario. (It will log all REST calls that the library makes, as well as details about signing.) Note that the library does not hide any authentication info, so your logs may contain sensitive data. This makes any potential problems easier to diagnose.

Internals

If you would like to look at the internals of the library, please do, but be aware that we will be iterating over the next several releases, drastic changes may occur. If you would like to run the tests, you will need to provide your own credentials in the test_configurations.json file. You will also have to change the scheme to actually build and run the tests, and you may need to enable code signing as well.

azure-storage-ios's People

Contributors

asorrin-msft avatar esummers-msft avatar mannie avatar microsoft-github-policy-service[bot] avatar micurd avatar zezha-msft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-storage-ios's Issues

I'm receiving Failed to emit precompiled header for bridging header

Which version of the SDK/iOS was used?

Xcode 10/ Swift 3

What problem was encountered?

I'm receiving Failed to emit precompiled header for bridging header when building your BlobSample project after installing cocoa pods and running in the workspace

Have you found a mitigation/solution?

No, that's why I'm opening this ticket.
I've tried the accepted answer under:
https://stackoverflow.com/questions/45779591/failed-to-emit-precompiled-header-for-bridging-header - still no luck

+[AZSCloudStorageAccount accountFromConnectionString:error:]: unrecognized selector sent to class

I just updated to whatever the latest version is via cocoapods and I'm getting this error when trying to instantiate an AZSCloudStorageAccount object via swift:

ex:
let account = try! AZSCloudStorageAccount(fromConnectionString: "DefaultEndpointsProtocol=https;AccountName=\(accountName!);AccountKey=\(accountKey!)")

this worked fine before the update minus the try! since the call now throws.

Can't build with bitcode

I'm trying to use this with a much larger project, but linker complains that I have to compile with bitcode, as the larger project uses bitcode. Even when I change the build settings to compile using bitcode, it still doesn't work. Anyone else have this problem? Due to the size of the project I simply cannot submit without bitcode.

How to [AZSCloudBlockBlob initWithUrl]

How can i initialize an AZSCloudBlockBlob with a url (which i get from an API that returns SASurls). In the AZSBlobSasTests.m file AZSUriQueryBuilder is used to create the url for the initialization. But i can't import AZSUriQueryBuilder .hin my file.

https://github.com/Azure/azure-storage-ios/blob/5ddb81d20e9acb7bd8db8ed7f55a6b96d6f78cdc/Lib/Azure%20Storage%20Client%20Library/Azure%20Storage%20Client%20LibraryTests/AZSBlobSasTests.m

I tried to split the url from my API to the format which works on the Windows client, but with no success. Any help is appreciated.
Thank you

com.Microsoft.AzureStorage.ErrorDomain error 3

I get this error quite often:
The operation couldn’t be completed. (com.Microsoft.AzureStorage.ErrorDomain error 3.)

I'm using blobstorage with SAS, and the only thing I can do once I get this error seems to be to get a new SASURI and try again. Why does this happen, and is there anything I can do to avoid these?

Adding some code here for context:

`
let url = URL(string: doc.resourceUri!)
let storageUri = AZSStorageUri(primaryUri: url!)
var error:NSError?
let blob = AZSCloudBlockBlob(storageUri: storageUri, error: &error)

    blob.upload(from: data, completionHandler: { (error:Error?) -> Void in
        if error != nil && error?.localizedDescription != nil
        {
            let failureDescription = error?.localizedDescription
            doc.uploadStatus = UploadStatus.default.rawValue as NSNumber?
            doc.resourceUri = nil
            appdelegate.saveContext()
            self.blobCheckInProgress = false
            return
        }
        else
        {
            doc.uploadStatus = UploadStatus.uploaded.rawValue as NSNumber?
            doc.expense?.syncronized = NSNumber(value : false)
            doc.travelExpenseEntry?.syncronized = NSNumber(value : false)
            doc.travelExpenseEntry?.travelExpense?.syncronized = NSNumber(value : false)
            
            if StaticOperations.stringIsNilOrEmpty(input: doc.temporaryId)
            {
                doc.temporaryId = UUID().uuidString
            }
        }
        
        appdelegate.saveContext()
        self.blobCheckInProgress = false
        self.checkForBlobsToUpload()
    })`

Azure Storage breaks when I call AZSCloudBlob in Swift

I've followed this article: Azure Storage Client Library for iOS and their sample works. But now I am trying to bring the azure-related code to my own project. I added the framework per instructions and show up like this in my project:
screen shot 2016-06-01 at 2 52 20 am

But when I uncomment the 3rd line and try to build:
var containerURL: String = "" let usingSAS = true var blobs = [AZSCloudBlob]() // uncommenting this results into build error //var container : AZSCloudBlobContainer = AZSCloudBlobContainer() //var continuationToken : AZSContinuationToken?

I get this build error:

screen shot 2016-06-01 at 2 27 06 am

I've modeled my setting like this:
screen shot 2016-06-01 at 2 26 25 am

"AZSClient/AZSClient.h" file not found

got this error message after update. I followed steps in readme, and added
#import "AZSClient/AZSClient.h"
to my bridging header. Also tried
#import <AZSClient/AZSClient.h>

[Swift] Missing Nullability in AZSCloudBlockBlob upload:from:completionHandler:

Hi,

I've installed AZSClient throught CocoaPods. I'm using swift in my development and I want to upload a blob with contents from Data object; however, in completionHandler, type of error is Error, not Error?, therefore swift warns me that it can never be null. With a non-nullable error, I cannot check whether upload is successful or not, even worse, app may crash when Obj-C code tries to return nil. I haven't runned it, but it is likely to cause problem.

Other upload methods does not have this problem, I can use upload:from:accessCondition:requestOptions:operationContext:completionHandler by giving null to all other parameters for now. But I hope you'll fix this bug as soon as possible.

Have a nice day!

Xcode 8, swift 3- redefinition of module 'asl'

Hi, I have been using AZSClient for a while, but got into a shitstorm of errors when using xcode 8 and swift 3. And once again it seems that asl is at the centre of the issue. Reproduce by simply downloading xcode 8 gm and start a new project, then import AZSClient through cocoapods.

Naming convention and import path

#import "Azure Storage Client Library/Azure_Storage_Client_Library.h"

is this actually idiomatic in Objective-C/Cocoa SDK?

I've never seen:

  • directory names with spaces
  • header files with underscores

also class names in this library starts with AZ, but the import statement does not have AZ in it.

Take a look at these examples:

#import <UIKit/UIKit.h>
...
UINavigationController* n = ...
#import "AFNetworking/AFNetworking.h>
...
AFHTTPRequestSerializer* s = ...

So I think this library should be something like:

#import "AZStorage/AZStorage.h"

because:

  • _Client = obvious
  • _Library = obvious

Archive the project show error!!!

ld: warning: ignoring file /Users/ty19891833/Desktop/Servant/AZSClient.framework/AZSClient, missing required architecture armv7 in file /Users/xxx/Desktop/Servant/AZSClient.framework/AZSClient (2 slices)
Undefined symbols for architecture armv7:
"OBJC_CLASS$_AZSCloudStorageAccount", referenced from:
objc-class-ref in ServerConfiguration.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

need your answer!

Blob upload fails with 400 error code quite randomly

Sometimes (reported by a customer) when sending pictures (SDK 0.2.4) with below code, we get the 400 error (InvalidBlockList) also listed below.
It seems quite random, I couldn't really reproduce this error, and customer also can retry successfully.
But this makes the whole transmission to fail, so it's not good.
I couldn't find any solution to retry such failing request either (at least not for iOS SDK).

Is there some solution for this? How to retry on such failing request? It should be possible, since manual retry is OK.

func uploadFileToBlob(container: String = Config.photosContainer, viewController: UIViewController, uuid: String, pictureSection: String, fileName: String, data: Data, completion: @escaping ((String?) -> Void)) {
        
        if let _ = self.account {
            let blobClient = self.account?.getBlobClient()
            
            let blobContainer = blobClient?.containerReference(fromName: container)
            let blobDirectory = blobContainer?.directoryReference(fromName: String(format: "%@/%@", uuid, pictureSection))
            let blockBlob = blobDirectory?.blockBlobReference(fromName: fileName)
            
            let options = blobClient?.defaultRequestOptions
            options?.maximumExecutionTime = 30
            blockBlob?.upload(from: data, accessCondition: nil, requestOptions: options, operationContext: nil, completionHandler: {(error: Error?) -> Void in
                
                if let _ = error {
                    completion(error.debugDescription)
                } else {
                    completion(nil)
                }
            })
        }
    }

Error sending picture for vehicle chassis 123456. Section/picture: 4/3. Error description: Optional(Error Domain=com.Microsoft.AzureStorage.ErrorDomain Code=3 "(null)" UserInfo={HTTP Status Code=400, rawErrorData=<CFData 0x170d3c10 [0x382267d8]>{length = 221, capacity = 221, bytes = 0xefbbbf3c3f786d6c2076657273696f6e ... 3c2f4572726f723e}, URLResponse=<NSHTTPURLResponse: 0x17288510> { URL: https://volvovikingqa.blob.core.windows.net/photos/path/1?comp=blocklist } { status code: 400, headers {
"Content-Length" = 221;
"Content-Type" = "application/xml";
Date = "Thu, 10 May 2018 12:13:37 GMT";
Server = "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0";
"x-ms-request-id" = "a5f337c1-e01e-0015-5058-e89493000000";
"x-ms-version" = "2015-04-05";
} }, OperationContext=<AZSOperationContext: 0x171acd30>, Code=InvalidBlockList, AdditionalErrorDetails={
}, RequestResult=<AZSRequestResult: 0x17228300>, Message=The specified block list is invalid.
RequestId:a5f337c1-e01e-0015-5058-e89493000000
Time:2018-05-10T12:13:37.6086268Z})

SAS Token from a Shared Access Policy

Which version of the SDK/iOS was used?

latest (0.2.6)

What problem was encountered?

how to generate a SAS-token from a blob-container's Access-Policy, from the iOS Client SDK?

Also is this SDK being worked on? -if so when will there be another release?

Have you found a mitigation/solution?

no.

pod install is failing

Hello,

I am trying to use this library in a brand new project and it fails:

  • I create a new empty folder
  • I create inside this directory a Xcode project "Empty" (with a single view iOS project with Xcode and just save)
  • I create a file "Podfile" with the following content:

xcodeproj 'Empty/Empty'
target 'Empty' do
pod 'AZSClient', '~> 0.2.2'
end

  • I run "pod install" and get:

Analyzing dependencies
Downloading dependencies
Installing AZSClient (0.2.2)
[!] /bin/bash -c
set -e
asl/injectXcodePath.sh
/bin/bash: asl/injectXcodePath.sh: /bin/sh^M: bad interpreter: No such file or directory

I am using macOS Sierra, XCode 8.1 and pod 1.1.1 (the latest version of the tools basically).

x-ms-blob-type

I am creating AZSCloudBlockBlob with SAS URL I obtain from our backend. Then I try to upload data, seeing response of HTTP 403 with message: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature...

var error: NSError?
let blockBlob = AZSCloudBlockBlob(url: mySASURL, error: &error)
blockBlob.upload(from: data) { (error) in
  // http 403
}

Solution: I inspected the request this framework creates and discovered that header with key x-ms-blob-type is missing. And according to ms docs is required. Using Postman, I created this PUT request including x-ms-blob-type and it works.

Unspecified error when initializing storage account in sample app

Xcode 8.2.1

When running sample app (and before, when running my own app via Cocoapods) I get this error when initializing AZSCloudStorageAccount: Error Domain=com.Microsoft.AzureStorage.ErrorDomain Code=1 "(null)"

from the line try! storageAccount = AZSCloudStorageAccount(fromConnectionString: connectionString) in BlobListTableViewController.swift

Any advice on how to debug to nail down the error further would be great!

Can we get specific definitions for the AZS Errors Listed?

#ifndef AZS_ERRORS_DEFINED
#define AZS_ERRORS_DEFINED
FOUNDATION_EXPORT NSString *const AZSErrorDomain;
FOUNDATION_EXPORT NSString *const AZSInnerErrorString;

#define AZSEInvalidArgument 1
#define AZSEURLSessionClientError 2
#define AZSEServerError 3
#define AZSEMD5Mismatch 4
#define AZSEClientTimeout 5
#define AZSEParseError 6
#define AZSEXMLCreationError 7
#define AZSEOutputStreamError 8
#define AZSEOutputStreamFull 9

#endif //AZS_ERRORS_DEFINED

Completion Handler

Which version of the SDK/iOS was used?

0.2.6

What problem was encountered?

I am uploading pictures to my Azure Blob Storage. I encounter wrong transfer on slow speed mobile internet connections and corrupted(not present) images on my server. The completion handler of the below function should return a fault on a unsuccessful transfer of my images, but it always gives me the answer that everything was fine!!
I am using this for payment and my customers upload their images. On success I open a payment window and my customers pay for my service. Now, I get payments, but sometimes the images are not on the server, cause of the transfer problems! I had to remove the App from App Store!!!

I can see following on slow speed mobile internet connections (EDGE) only (this never happens with high speed or WiFi connections!):

Upload progress in %: 10
DataUsageInfo(wifiReceived: 11090392, wifiSent: 1459193, wirelessWanDataReceived: 877855, wirelessWanDataSent: 1585215)
Upload progress in %: 10
2018-07-28 12:46:25.021824+0200 xxxxxxx[273:15018] [] tcp_connection_write_eof_block_invoke Write close callback received error: [89] Operation canceled
2018-07-28 12:46:25.023432+0200 xxxxxxx[273:15018] [] tcp_connection_write_eof_block_invoke Write close callback received error: [89] Operation canceled
DataUsageInfo(wifiReceived: 11090392, wifiSent: 1459193, wirelessWanDataReceived: 877855, wirelessWanDataSent: 1585215)
Upload progress in %: 10
DataUsageInfo(wifiReceived: 11090392, wifiSent: 1459193, wirelessWanDataReceived: 877855, wirelessWanDataSent: 1585215)
Upload progress in %: 10\

So there is a TCP error, but the transfer of the blob is not stopped nor a fault is catched/shown by the completion handler and that leads to not existing files/images on my cloud Blob Storage account!

The completion handler does not show a error message, when the transfer of image was unsuccessful.

//Upload to Azure Blob Storage with help of SAS
func uploadBlobSAS(container: String, sas: String, blockname: String, fromfile: String ){

// If using a SAS token, fill it in here.  If using Shared Key access, comment out the following line.
let containerURL = "https://xxxxxxx.blob.core.windows.net/\(container)\(sas)"  //here we have to append sas string: + sas
    print("containerURL with SAS: \(containerURL) ")
var container : AZSCloudBlobContainer
var error: NSError?
    
container = AZSCloudBlobContainer(url: NSURL(string: containerURL)! as URL, error: &error)
if ((error) != nil) {
print("Error in creating blob container object.  Error code = %ld, error domain = %@, error userinfo = %@", error!.code, error!.domain, error!.userInfo);
}
else {

    let blob = container.blockBlobReference(fromName: blockname)
    blob.uploadFromFile(withPath: fromfile, completionHandler: {(NSError) -> Void in
        
        if (error != nil){
            //!!!!!!! NEVER GETS HERE EVEN IF THE TRANSACTION WAS UNSUCCESSFULL !!!!!!!!!!!
            
        }
        else {
            NSLog("Ok, uploaded !")
            //3. Leave dispatch group
            self.taskGroup.leave()
        }  
    })
    }

}

Have you found a mitigation/solution?

Not a real solution, but a workaround to this bug. I now check every file if it is present on the server after the completion handler shows me that everything was fine...if the files are not there I show now a error message.

Include of non modular header

I am trying to use the library via cocoa pods,

pod 'AZSClient'

ran pod install and everything went well

but when I try to use it in the project

import AZSClient

Project doesn't build

screen shot 2016-02-11 at 5 12 31 pm

I am using in a swift project

Any help much appreciated

Offline Sync

Will there be an Offline Sync to the Blob Storage?

Thanks.

upload from file: the 'completionHandler' is not called.

Version 0.2.4, install from cocoapods
Project: iOS with swift.

I have an image file to upload (file: URL)

I use AZSCloudBlockBlob to upload this image file

let blockBlob = container.blockBlobReference(fromName: name);
blockBlob.uploadFromFile(with: file) { (error) in
       print("Result with Error: \(error)")
}

With good internet, the callback (completionHandler) is called after success.
With bad network:

  • Start above code with a taken image.
  • Turn internet off in 30 seconds
  • Turn internet on in 3 or 5 seconds
  • Turn internet off in 20 seconds
  • Turn internet on.

=> The callback is not called

I am working with a project that uses this framework, an task is related to this bug need to be released urgently. Please work on it

Issue with AZSNullable types when called from swift code

Hi, I'm using the this library from cocoapods but I detected an issue with the method
-(void)uploadFromData:(NSData )sourceData completionHandler:(void (^)(NSError AZSNullable))completionHandler;
and probably other methods, when calling them from swift code, in my case I'm calling this method like this:

   :
   :
   blob.upload(from: data, completionHandler: {(error) in
        if error != nil {
                //print the error
        } else {
	            //success
        }
  })

And the issue is that the property "error" in the closure doesn't have the correct type because the app crashes (on real devices) and also I get this warning "Comparing non-optional value of type 'Error' to nil always returns true" in this line:
if error != nil {
:

it's saying that the error cannot be nil but it is nil when the upload is success, and that's correct because the description of the method says the following: "NSError* will be Nil if the operation succeeded without error, error with details about the failure otherwise", as you can see in the declaration (found in AZSCloudBlockBlob.h)

Parameter name Description
NSError * Nil if the operation succeeded without error, error with details about the failure otherwise.

-(void)uploadFromData:(NSData *)sourceData completionHandler:(void (^)(NSError * AZSNullable))completionHandler;

I can avoid this error by changing the type from (NSError* AZSNullable) to (NSError* __AZSNullable), but even after that xcode is showing some warnings in the implementation of this method from swift code.

Can you please review these methods to ensure they work correctly when called from Swift?

Thanks in advance

Failed to compile from source

I am trying to follow the steps from the README:

  • clone the master branch
  • open the xcode project
  • compile the AZSClient library
  • compile the framework target: at this poing I get a strange "xcrun: error: Unknown build action 'xcodebuild'."

I am using the latest XCode 8.1 on MacOS Sierra.

Version 0.2 not available as PodFile

Hi, just tried to use this as a pod, but could not find the latest version. Also downloaded the source, and found that there is still an issue with conversion from long long to NSUInteger.

Background session configuration for uploads

In one of our applications we actively using background NSURLSession for big uploads https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1407496-backgroundsessionconfigurationwi?language=objc.

Users are unlikely to keep the app in foreground for a long time, so it is important for us that the upload continues even if app is sent to background. Or even if app is terminated.

Could somebody from the maintainers respond, please, whether

  1. it should in theory be possible to use background NSURLSession uploads with Azure Storage
  2. how big of a deal it would be to update this library to use background uploads

We are currently considering what are our options in transitioning to Azure Storage. Whether we should use this library or if it makes sense to make our own component to handle uploads (which would support background NSURLSession).

Thanks!

Error when running the Swift project on device

I setup the project like the instructions. My setup is like pic.1 and When I connect my iPhone device and my containerURL value generated like pic.2. when I run the project, I get the error in pic.3 No line is highlighted in regular code.
is my setup working? Should the current code work for Swift!?

screen shot 2016-05-25 at 8 18 34 pm
screen shot 2016-05-25 at 8 21 45 pm
screen shot 2016-05-25 at 8 28 18 pm

Blob upload fails with 400 error code and the Message warning

task.error:Error Domain=com.Microsoft.AzureStorage.ErrorDomain Code=3 "(null)" UserInfo={Code=InvalidHeaderValue, AdditionalErrorDetails={
HeaderName = "Content-MD5";
HeaderValue = "SAVEFILE/20180710/7ed8de1db07b40dba99b2bd66ff60cc2.png";
}, rawErrorData=<CFData 0x1353c2840 [0x1b433a538]>{length = 371, capacity = 371, bytes = 0xefbbbf3c3f786d6c2076657273696f6e ... 3c2f4572726f723e}, OperationContext=<AZSOperationContext: 0x1352ca470>, RequestResult=<AZSRequestResult: 0x1353c7190>, HTTP Status Code=400, URLResponse=<NSHTTPURLResponse: 0x1353c6ea0> { URL: https://exce.blob.core.chinacloudapi.cn/o-test/exce?comp=block&blockid=exce } { Status Code: 400, Headers {
"Content-Length" = (
371
);
"Content-Type" = (
"application/xml"
);
Date = (
"Tue, 10 Jul 2018 09:09:56 GMT"
);
Server = (
"Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0"
);
"x-ms-request-id" = (
"7488ed28-201e-0056-4e2d-1849c3000000"
);
"x-ms-version" = (
"2015-04-05"
);
} }, Message=The value for one of the HTTP headers is not in the correct format.
RequestId:7488ed28-201e-0056-4e2d-1849c3000000
Time:2018-07-10T09:09:56.8943944Z}

upload from file - delete file while uploading

Dear Developers,

I am maintaining a product that uses AZSClient framework to upload images.

I save image to file first, then perform upload by AZSCloudBlockBlob:

  • If everything is good, the completionCallback called with error = nil
  • If I perform a code to delete this file while uploading, the completionCallback called with error = nil. I think error should be an Error object
let blockBlob = container.blockBlobReference(fromName: name);
blockBlob.uploadFromFile(with: file) { (error) in
       print("Result with Error: \(error)")
}

DateFormatterWithFormat is not thread safe

When attempting to retrieve blob attributes we encounter an occasional application crash pointing to [df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:AZSCPosix]]; can this be synchronized?

`+(NSDateFormatter *) dateFormatterWithFormat:(NSString *)format
{
static NSDateFormatter *df = nil;
if (!df) {
df = [[NSDateFormatter alloc] init];
[df setLocale:[[NSLocale alloc] initWithLocaleIdentifier:AZSCPosix]];
[df setCalendar: [[NSCalendar alloc] initWithCalendarIdentifier:AZSGregorianCalendar]];
[df setTimeZone:[NSTimeZone timeZoneWithName:AZSCUtc]];
}

NSDateFormatter *dateFormat = [df copy];
[dateFormat setDateFormat:format];
return dateFormat;

}`

Register for upload/download progress updates

I we use the library to upload big chunks of data and I couldn't find an easy way to expose the current upload progress.

It seems possible after having a AZSBlobOutputStream from a Blob reference. But I rather like to have it e.g. with the uploadFromText method.

uploadFromFile never reaches completion handler

I have modified the sample, as I want to upload a file, rather than text in body of request.

The completion handler on uploadFromFile never occurs. The standard upload uploads a file fine to the container.

There are no errors in the output window in Xcode.

I have tried this with small files (1Mb and larger 20Mb files)

                if let resourcePath = Bundle.main.resourcePath {
                    let imgName = "smallimage1mb"
                    let path = resourcePath + "/" + imgName
                    let localURL = URL(string: path)
                    
                    let storageAccount : AZSCloudStorageAccount;
                    try! storageAccount = AZSCloudStorageAccount(fromConnectionString: connectionString)
                    
                    let blobClient = storageAccount.getBlobClient()
                    let options = blobClient.defaultRequestOptions
                    options?.maximumExecutionTime = 30
                    
                    let blockBlob = container!.blockBlobReference(fromName: name)
                    blockBlob.uploadFromFile(with: localURL!, accessCondition: nil, requestOptions: options, operationContext: nil, completionHandler: {(error: Error?) -> Void in
                        
                        if let _ = error {
                            print(error.debugDescription)
                        } else {
                            print("success")
                        }
                    })
                    
                    
                    blockBlob.upload(fromText: textTextField.text ?? "",  completionHandler: { (error: Error?) -> Void in
                        if (self.viewToReloadOnBlobAdd != nil) {
                            self.viewToReloadOnBlobAdd!.reloadBlobList()
                        }
                    })
                }

Need file support!

Or maybe could you explain if it is possible to work with files+folders via blobs?

listBlobsSegmentedWithContinuationToken method generates errors

I got this code from this github: [azure-storage-ios/BlobSample/][1]
I am able to create my container and add blobs to it. I verified they are there in the azure portal. I am using the SAS token method per this:

var containerURL = "https://<mystorage>.blob.core.windows.net/profiles?se=2016-09-05T00%3A00%3A00Z&sp=rw&sv=2015-02-21&sr=c&sig=<mysig>"
var usingSAS = true
self.container = AZSCloudBlobContainer(url: NSURL(string: containerURL)!, error: &error)
// ... later:
blob.uploadFromText(textTextField.text ?? "",  completionHandler: { (error: NSError?) -> Void in

})

But now, I am trying to load blob but receive one or more errors!

func reloadBlobList() {
    self.container.listBlobsSegmentedWithContinuationToken(nil, prefix: nil, useFlatBlobListing: true, blobListingDetails: AZSBlobListingDetails.All, maxResults: 50) { (error : NSError?, results : AZSBlobResultSegment?) -> Void in
        if let error = error {
            print("error code! \(error.code)")
            print("error description! \(error.description)")
        }

I get this error about AuthorizationPermissionMismatch mainly

error code! 3
error description! Error Domain=com.Microsoft.AzureStorage.ErrorDomain Code=3 "(null)" UserInfo={Code=AuthorizationPermissionMismatch, AdditionalErrorDetails={
}, rawErrorData=<CFData 0x13764edb0 [0x1a17c6150]>{length = 279, capacity = 279, bytes = 0xefbbbf3c3f786d6c2076657273696f6e ... 3c2f4572726f723e}, OperationContext=<AZSOperationContext: 0x137651330>, RequestResult=<AZSRequestResult: 0x137697b60>, HTTP Status Code=403, URLResponse=<NSHTTPURLResponse: 0x13756c640> { URL: https://.blob.core.windows.net/profiles?sig=&api-version=2015-04-05&sp=rw&se=2016-09-05T00%3A00%3A00Z&sv=2015-02-21&sr=c&restype=container&comp=list&maxresults=50&include=snapshots,metadata,uncommittedblobs,copy } { status code: 403, headers {
"Content-Length" = 279;
"Content-Type" = "application/xml";
Date = "Fri, 27 May 2016 08:12:19 GMT";
Server = "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0";
"x-ms-request-id" = "90746e2f-0001-0114-7eef-b7be1e000000";
"x-ms-version" = "2015-04-05";
} }, Message=This request is not authorized to perform this operation using this permission.
RequestId:90746e2f-0001-0114-7eef-b

the key I generated earlier had the r/w permission and I was able to post blobs to the container, what else should I've done for the retrieval?

Support Table Operation in IOS

Hi Azure Team,

Like android support table related operation ,why not in IOS?
When you add table support operation in IOS?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.