Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

downloadToFile not working first time #99

Open
VickyPrajapati24 opened this issue Oct 26, 2019 · 3 comments
Open

downloadToFile not working first time #99

VickyPrajapati24 opened this issue Oct 26, 2019 · 3 comments

Comments

@VickyPrajapati24
Copy link

VickyPrajapati24 commented Oct 26, 2019

Which version of the SDK/iOS was used?

pod 'AZSClient', '~> 0.2.6'

What problem was encountered?

After the fresh installation of my app, the first time when I call downloadToFile method completion block not called. It won't give error nor a failure. Downloading goes to infinity. After restarting app then onwards it will work all the time.
If I use downloadToText and it works all the time. downloadToFile not working the first time. I have to download the ZIP file so I have to always go for downloadToFile method.

Have you found a mitigation/solution?

No, I have tried to download one dummy file on the app launch but still, downloadToFile method completion block won't be called.

Code:

func sampleBlobDownload() {
        do {
            // Create a storage account object from a connection string.
            let connectionString = String(format: "DefaultEndpointsProtocol=https;AccountName=%@;AccountKey=%@", kBlobAccountName, kAccountKey)
            let account = try AZSCloudStorageAccount(fromConnectionString: connectionString)

            // Create a blob service client object.
            let blobClient = account.getBlobClient()

            // Create a local container object.
            let blobContainer = blobClient.containerReference(fromName: kBlobAccountName)
            
            // Create container in your Storage account if the container doesn't already exist
            blobContainer.createContainerIfNotExists(with: .container, requestOptions: nil, operationContext: nil, completionHandler: { error, _ in
                if error != nil {
                    print("Error in creating container.")
                } else {
                    //Create a local blob object=
                    let docDir = MasterDownloader.shared.getDocumentDirectoryPath()
                    let destinationURL = docDir.appendingPathComponent("abc.txt")
                    let blockBlob = blobContainer.blockBlobReference(fromName: "abc.txt")
                    
                    blockBlob.downloadToFile(with: destinationURL, append: true) { (error) in
                        if error != nil {
                            print("Error in downloading from blob")
                        } else {
                            print("Downloaded")
                        }
                    }
                    
// Download To text function works all time but donwloadToFile not work first time.
//                    let blockBlob = blobContainer.blockBlobReference(fromName: "abc")
//                    blockBlob.downloadToText { (error, text) in
//                        if error != nil {
//                            print("Error in uploading to blob")
//                        } else {
//                            print(text)
//                        }
//                    }
                }
            })
        } catch let error {
            print(error)
        }
    }
@VickyPrajapati24
Copy link
Author

Please revert to this. I am still facing this issue.

@VickyPrajapati24
Copy link
Author

can anyone please help me out on this.

@VickyPrajapati24
Copy link
Author

can anyone please help me on this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant