ricardorauber / StrapiSwift

A Swift toolkit to connect to your Strapi backend
MIT License
10 stars 3 forks source link

Unable to use the upload #1

Closed xrofa closed 3 years ago

xrofa commented 3 years ago

On my Strapi I have the default User (from "user-permissions"), and I have on it a field called "picture". Using the upload I'm doing something like this:


                contentType: "user",
                id: 1,
                field: "picture",
                image: profilePicture,
                compressionQuality: 90) { response in

                guard let record = response.dictionaryValue() else {
                    return
                }
                print("Some data: \(record)")
            }```

But I keep having a 500 error even if I let an unauthenticated user try to upload something.
What am I doing wrong here? Thanks
xrofa commented 3 years ago

For anyone stuggling with the same as I had, use this instead: `strapi.upload( contentType: "user", id: 1, field: "picture", source: "users-permissions", path: nil, filename: "myPic.jpg", mimeType: "image/jpg", image: profilePicture!, compressionQuality: 90, interceptor: interceptor, autoExecute: true) { (response) in

            guard let record = response.dictionaryValue() else {
                return
            }
            guard let error = record["error"] else {
                return
            }
            print("got some error!: \(error)")
        }`