filestack / filestack-ios

Official iOS SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
MIT License
54 stars 36 forks source link

Swift SDK appears to generate incorrect URL for transforms #67

Closed brynjar closed 4 years ago

brynjar commented 4 years ago

pod 'FilestackSDK', '2.3.1'

I'm trying to use your SDK to resize an image I previously successfully uploaded to S3 (via the upload call) and from which I got a handle.

func transform(path: String, filename: String, handle: String, completion: @escaping (String, String) -> Void) {

        let transformable = filestackClient.transformable(handle: handle)
        transformable.add(transform: ResizeTransform().width(150).height(200))
        let storeOptions = StorageOptions(location: .s3, path: "a", filename: "b", mimeType: "image/jpeg", access: .private)

        transformable.store(using: storeOptions, base64Decode: false) { (handle, response) in

        if let json = response.json,
            let key = json["key"] as? String,
            let url = json["url"] as? String {
            completion(key, url)
        } else {
            completion("", "")
        }

        }

    }

This generates a URL like

https://www.filestackapi.com/api/store=location:S3,path:a,filename:b,access:private,base64decode:false/security=policy:[policy],signature:[sig]

which returns HTTP 404 as the result of the POST call. I know my client is configured correctly (policy/sig) since the upload call works.

It appears that something like https://www.filestackapi.com/api/store/S3?xyz would be valid.

Am I doing something wrong?

rnine commented 4 years ago

@brynjar Hi. You're not doing anything wrong, the base URL should be https://cdn.filestackcontent.com instead of https://www.filestackapi.com/api, hence that's a bug in our code.

I'll prepare a new release with this fix and close this issue. Feel free to reopen if you still experience any issues!

Thanks!