Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

ingconti's avatar
ingconti
Helpful | Level 5
4 years ago

Re: Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg":

good you are available

Said so, pls let me know How to fix it.

to recap:

a) my ap is written in swift, NO other components (neither official dropbox library, too big and too messy)

b) it did work since 2 month ago. now I got error

c) if I cannot see WHAT has been broken, pls sent me HINTS about, OR let mr speak with some tech guy of upper level, to get some helpful tips.

14 Replies

  • ingconti's avatar
    ingconti
    Helpful | Level 5
    4 years ago

    seems working !

     

    THX

     

    I used a reduced version for simple string, as path:

     

     

    func DB_utf8Decode(_ data: Data) -> String {

        return NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String

    }

     

     

    func DB_asciiEscape(_ s: String) -> String {

        var out: String = ""

     

        for char in s.unicodeScalars {

            var esc = "\(char)"

            if !char.isASCII {

                esc = NSString(format:"\\u%04x", char.value) as String

            } else {

                if (char == "\u{7F}") {

                    esc = "\\u007f"

                } else {

                    esc = "\(char)"

                }

            }

            out += esc

     

        }

        return out

    }

     

     

     

  • ingconti's avatar
    ingconti
    Helpful | Level 5
    4 years ago

    as a last side note:

    you had to write:

    • C# (2 cersions)
    • java
    • JavaScript
    • Objective-C

    • Python

    • PHP

    • Swift

     

    So 8 versions when simply accepting binary JSON on server would have prevented all this stuff? and / or fixing on server directly?

     

    seems,  as minimum, suboptimal.

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    Thanks for following up. I'm glad to hear you got this working, and thanks for the feedback!

  • ingconti's avatar
    ingconti
    Helpful | Level 5
    4 years ago

    a more "swift" solution for string with a copiale of Unit test:

     

    func DB_asciiEscape(_ s: String) -> String {

        

        let out = s.unicodeScalars.reduce("", { (partialResult: String, char: UnicodeScalar) -> String  in

        

            if !char.isASCII {

                return partialResult + String(format:"\\u%04x", char.value)

            } else {

                if (char == "\u{7F}") {

                    return partialResult + "\\u007f"

                } else {

                    return partialResult + "\(char)"

                }

            }

        }

        )

     

        return out

    }

     

     

     

    //------ UNIT TESTS:

     

     

        

        func testUtf8Decode(){

            

            let unescaped = "/OUT/aaaaa_000.jpg"

            let escaped  = DB_asciiEscape(unescaped)

            print(escaped)

            

            let contains = escaped.contains("uff3f000.jpg")

            XCTAssert(contains, "not ecaped")

        }

        

        

        func testUtf8Decode2(){

            

            let unescaped = "αβγ.jpg"

            let escaped  = DB_asciiEscape(unescaped)

            print(escaped)

            

            let contains = escaped.contains("\\u03b1\\u03b2\\u03b3")

            XCTAssert(contains, "not ecaped")

            

        }

     

     

     

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!