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

Calls run but completions are never returned? #804

Closed
BenQF opened this issue Dec 10, 2021 · 9 comments
Closed

Calls run but completions are never returned? #804

BenQF opened this issue Dec 10, 2021 · 9 comments
Assignees
Labels

Comments

@BenQF
Copy link

BenQF commented Dec 10, 2021

  • [ x] I have checked that the SDK documentation doesn't solve my issue.
  • [ x] I have checked that the API documentation doesn't solve my issue.
  • [ x] I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
  • [ x] I have searched Issues in this repo and my issue isn't already reported.

Description of the Issue

When using client.files.upload the call runs and can even show progress but the completion is never returned. We've tried this in a fresh program with box using the example calls from the box api reference for iOS, and using sdk 5.0.0. The call seems to run and send the file to box but the completion never calls success and no body is returned from the call.

let task: BoxUploadTask = client.files.upload(data: data, name: "Test File.txt", parentId: self.fileId) { (result: Result<File, BoxSDKError>) in
guard case let .success(file) = result else {
print("Error uploading file")
return
}

print("File \(file.name) was uploaded at \(file.createdAt) into \"\(file.parent.name)\"")

}

Steps to Reproduce

Running this code in a new program with our token and client authenticated provides this return

▷ POST https://upload.box.com/api/2.0/files/content
▷ Headers:
▷ X-Box-UA, Value: agent=box-swift-sdk/5.0.0; env=iPhone XS/15.1
▷ Authorization, Value: Bearer ***removed but auth header was valid
▷ Body: Multipart

This is the last response

Expected Behavior

Error Message, Including Stack Trace

No error message file lands in box but the completion doesn't return and we cannot see what the box file id for the file that submitted was.

Screenshots

Versions Used

iOS SDK: using iOS sdk 5.0.0
iOS Preview SDK:
iOS: iOS 15.1
Xcode: Xcode 13.1

@arjankowski
Copy link
Contributor

arjankowski commented Dec 10, 2021

Hi @BenQF,

Unfortunately I can not reproduce this issue on my local setup.
But file upload could take a while especially when the uploading file has a big size.

Is this is your case, please try with smaller one to make sure that it works.
Perhaps the log from request was displayed to console but after some time? Can you check this please?

What I can also suggest is to pass additional parameter progress to this function.
Thanks to this you can observe the current state of uploading the file.
Here is an example adjusted to your code:


let task: BoxUploadTask = client.files.upload(
    data: data,
    name: "Test File.txt",
    parentId: self.fileId,
    progress: { progress in print("Total progress: \(progress.fractionCompleted * 100)%") }) { result in
        switch result {
        case let .success(file):
            print("File uploaded successfully: \(file.id)")
        case let .failure(error):
            print("Error during upload: \(error)")
        }
    }

Let me know if this helps!

@BenQF
Copy link
Author

BenQF commented Dec 10, 2021

Hi @arjankowski
Thanks for the reply I had tried that as well since its nice to see progress,

▷ POST https://upload.box.com/api/2.0/files/content
▷ Headers:
▷ X-Box-UA, Value: agent=box-swift-sdk/5.0.0; env=iPhone XS/15.1
▷ Authorization, Value: Bearer Hiding
▷ Body: Multipart
"Total progress: 0.95%"
"Total progress: 1.9%"
"Total progress: 95.0%"
"Total progress: 100.0%"

Always the same outcome runs, uploads shows progress, lands in correct box folder, no completion call, additionally the test file I'm using is a 85 kb pdf, and i have tried others as well.

Additionally, I can call the endpoint directly with alamofire doing a post with headers files and params in the app and in postman and both work and receive a response.

let url = URL(string: "https://upload.box.com/api/2.0/files/content")
Alamofire.upload(multipartFormData: testData, to: url, method: .post, headers: ["Authorization":"Bearer " + token.value,"Content-Type":"multipart/form-data"],encodingCompletion: { encodingResult}

However any time we try and use the iOS sdk itself, we never receive the response.

Thanks for your assistance.

@arjankowski
Copy link
Contributor

Hi @BenQF,

On my setup which is below uploading a file works every time:

  • iOS: iPhone: 11/15.1
  • Xcode: Xcode 13.1
  • iOS SDK: 5.0.0

Is this possible that will you send me to an email sample file upload project that does not run for you?
Of course without any credentials and any private data.
This will help me find the cause of the error.

@BenQF
Copy link
Author

BenQF commented Dec 13, 2021

Hi @arjankowski
I uploaded a test project to github and added you on it. It just has our podfile, and a get client and upload call. Gets client uploads to box fine I can see the file, however no callback to the application.

The output I'm seeing appears like this in the file I've provided(with private data hidden for github).

▷ GET https://api.box.com/2.0/users/me?fields=name,login
▷ Headers:
▷ X-Box-UA, Value: agent=box-swift-sdk/5.0.0; env=iPhone Simulator/15.0
▷ Authorization, Value: Bearer Hidden
▷ Body:

◁ Status code: 200: no error
◁ Headers:
◁ Content-Type, Value: application/json
◁ box-request-id, Value: Hidden
◁ Content-Encoding, Value: gzip
◁ Cache-Control, Value: no-cache, no-store
◁ Strict-Transport-Security, Value: max-age=31536000
◁ Date, Value: Mon, 13 Dec 2021 16:52:12 GMT
◁ x-envoy-upstream-service-time, Value: 135
◁ Body: {"type":"user","id":"Hidden","name":"Hidden","login":"Hidden"}

▷ POST https://upload.box.com/api/2.0/files/content
▷ Headers:
▷ Authorization, Value: Bearer Hidden
▷ X-Box-UA, Value: agent=box-swift-sdk/5.0.0; env=iPhone Simulator/15.0
▷ Body: Multipart

@arjankowski
Copy link
Contributor

hi @BenQF,

In your repo I actually can see only one Init commit without any Box code sample.
Can you update it with changes you mention?

@BenQF
Copy link
Author

BenQF commented Dec 14, 2021

Hi @arjankowski
Pushed that update sorry about that.

@arjankowski
Copy link
Contributor

Hi @BenQF,

I've just pushed a PR for your repo with some working code.

The client has scope of the viewDidLoad method. So after execution of this method it's gone.

But to correctly execute a callback function a BoxClient instance should still exists, otherwise
it wont be executed like in your case. (See BoxClient.swift line 161).

To fix this please move the BoxClient declaration outside this method scope.

@arjankowski
Copy link
Contributor

Hi @BenQF

Is the problem still present and can I help somehow?

@BenQF
Copy link
Author

BenQF commented Dec 16, 2021

No you've been very helpful thanks!

@BenQF BenQF closed this as completed Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants