cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Shared Links in SwiftyDropbox broken?

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
Highlighted

Re: Shared Links in SwiftyDropbox broken?

Dropboxer
Dropboxer

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.

Highlighted

Re: Shared Links in SwiftyDropbox broken?

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

 

 

Highlighted

Re: Shared Links in SwiftyDropbox broken?

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)
}
Highlighted

Re: Shared Links in SwiftyDropbox broken?

Explorer | Level 3

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.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?