cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Shared Links in SwiftyDropbox broken?

Shared Links in SwiftyDropbox broken?

Mark L.45
Collaborator | Level 8

Running this function using SwiftyDropbox! Was working well til this morning, now it returns nothing useful, just the reply that the link already exists, and when I try and get the link... it returns nil.

 

Did see a post saying this functionality is broken right now. I hope not the case cause it is a single point of failure in my project!

 

Without shared links I am dead in the water.

 

func sharing_create_linkV2(sourcePath: String, posIndex: Int, group2join: DispatchGroup) {

        print("sharing_create_linkV2 \(sourcePath)")

        let client = DropboxClientsManager.authorizedClient!

        _ = client.sharing.createSharedLinkWithSettings(path: sourcePath).response(queue: DispatchQueue(label: "MyCustomSerialQueue")) { response, error in

            //_ = client.files.listFolder(path:sourcePath).response(queue: DispatchQueue(label: "MyCustomSerialQueue")) { response, error in

            if let response = response {

                group2join.leave()

                //print(Thread.current)  // Output: <NSThread: 0x61000007bec0>{number = 4, name = (null)}

                //print(Thread.main)     // Output: <NSThread: 0x608000070100>{number = 1, name = (null)}

                print("\(response.url) \(posIndex)")

                sharedDataAccess.fnLink(index2seek: posIndex, fnLink: response.url)

                sharedDataAccess.fnPos(index2seek: posIndex, fnPos: posIndex)

                

            } else {

                print("error \(error)")

                // error [request-id 4da78c6dd1e2c15fad08659eca204725] API route error - {

                //".tag" = "shared_link_already_exists";

                _ = client.sharing.getSharedLinkFile(url: sourcePath).response(queue: DispatchQueue(label: "MyCustomSerialQueue")) { response, error in

                    group2join.leave()

                    print("fcuk1510 data \(sourcePath) \(response?.0) \(response?.1 ) \(posIndex)")

                    sharedDataAccess.fnLink(index2seek: posIndex, fnLink: response?.0)

                    sharedDataAccess.fnPos(index2seek: posIndex, fnPos: posIndex)

                }

            }

        }

        

    }

4 Replies 4

Greg-DB
Dropbox Staff

Hi Mark, the known issue it sounds like you're refrrring to is an unexpected 403 error from /1/view links, which isn't related to the code you shared.

 

It sounds like you're seeing an unexpected result from getSharedLinkFile. You don't seem to be checking the error for that call in your code though. Can you print that out?

 

Also, for reference, if you're trying to get the existing shared link for a particular path, you should use listSharedLinks with path as the path to the file or folder and direct=true. The getSharedLinkFile method method takes a shared URL, not a path, and gives a download for the linked file. This is likely what the issue is, as it appears you're passing a path to this method.

Mark L.45
Collaborator | Level 8

Hi Greg,

 

Printed the errors, so I try to create a shared link. It fails with ...

 

sharing_create_linkV2 /acme201/acmeSINGLE/acmeX101.001.png

error Optional([request-id abc63bdac24b4afe306dae1d] API route error - {

    ".tag" = "shared_link_already_exists";

})

 

I ask for the shared link and I get...

 

error Optional([request-id 18b2cd24390e59cf83cedcef] API route error - {

    ".tag" = "shared_link_not_found";

}) source /acme201/acmeSINGLE/acmeX101.001.png response.0 nil response.1 nil 0

,/acme201/acmeSINGLE/acmeX101.001.png,0

 

Maybe I am asking the wrong question. I used the same string in both create link and return link API calls; but I am unclear if the API really works that way. The string I supply is the one you see here in bold/italics.  Create shared link wants a PATH, and yet get shared link suggests it needs a URL?

 

What do I need to add an HTTP://something? to the PATH when I call client.sharing.getSharedLinkFile API

 

 

Mark L.45
Collaborator | Level 8
*** STOP PRESS *** Managed to find a solution, used this code that works.

_ = client.sharing.listSharedLinks(path:sourcePath,cursor:nil,directOnly:false).response(queue: DispatchQueue(label: "MyCustomSerialQueue")) { response, error2 in


print("data error \(error2) source \(sourcePath) response.0 \(response?.links[0].url) \(posIndex)")
sharedDataAccess.fnLink(index2seek: posIndex, fnLink: (response?.links[0].url)!)
sharedDataAccess.fnPos(index2seek: posIndex, fnPos: posIndex)
}

tim
Explorer | Level 4

Just a note: if your code deals with a file that's in a folder which is also shared, then links[0].url will exist and be the shared link of the folder, not the file. If you want it to only return direct shared links, rather than use an ancestor's link, then specify directOnly as true.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    tim Explorer | Level 4
  • User avatar
    Mark L.45 Collaborator | Level 8
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?