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
55 stars 36 forks source link

Parameters are invalid for client.upload #47

Closed dimaportenko closed 5 years ago

dimaportenko commented 5 years ago

I'm trying following code


  @objc(upload:callback:)
  func upload(file: String, callback: @escaping RCTResponseSenderBlock) {
    let localURL = URL(string: file)!

    client?.upload(from: localURL, uploadProgress: { (progress) in
      // Here you may update the UI to reflect the upload progress.
      print("progress = \(String(describing: progress))")
    }) { (response) in
      // Try to obtain Filestack handle
      if let json = response?.json, let handle = json["handle"] as? String {
        // Use Filestack handle
        print(json)
        callback([json]);
      } else if let error = response?.error {
        // Handle error
        print(error)
        callback([error]);
      }
      print(response)
    }
  }

I'm getting progress data so I supose image is uploading. But getting error - aborted

here is print of response in the MultipartUpload.swift

(request: Optional(https://upload.filestackapi.com/multipart/complete),response: Optional(<NSHTTPURLResponse: 0x6000032664e0> { URL: https://upload.filestackapi.com/multipart/complete } { Status Code: 400, Headers {
    "Access-Control-Allow-Headers" =     (
        "Origin,Content-Type,Accept,User-Agent,UJID,UJID-Path,Filestack-Upload-Region,Filestack-Source"
    );
    "Access-Control-Allow-Methods" =     (
        "HEAD,OPTIONS,POST,PUT"
    );
    "Access-Control-Allow-Origin" =     (
        "*"
    );
    Allow =     (
        "HEAD, OPTIONS, POST, PUT"
    );
    Connection =     (
        "keep-alive"
    );
    "Content-Length" =     (
        128
    );
    "Content-Type" =     (
        "text/plain; charset=utf-8"
    );
    Date =     (
        "Thu, 13 Dec 2018 17:11:35 GMT"
    );
    Server =     (
        nginx
    );
    "X-Filestack-Apikey" =     (
        xxxxxxxxxxxxx
    );
} }), json: Optional(["i": , "c": {
    ujid = "c916857b-0a22-4305-9324-6f1055b610f2";
    "ujid_path" = "ul-0";
}, "error": Parameters are invalid, "t": 1544721095]), error: nil)

Am I doing anything wrong?

dimaportenko commented 5 years ago

Following pull request https://github.com/filestack/filestack-swift/pull/12 resolve issue

sgerardi commented 5 years ago

I am seeing the same issue. Has any progress been made on this?

dimaportenko commented 5 years ago

@sgerardi looks like dev team doesn't respond in the GitHub issues. The best solution at this moment to use pool request I've mentioned above.

sgerardi commented 5 years ago

I unfortunately need the UI provided by the Filestack-Swift repo which has this repo as a dependency. So I will probably just have to fork both to make it work.

kyuss commented 5 years ago

Hey guys. I will get back to that pull request and fix tests shortly but easiest workaround for now is to rollback to previous version of the filestack-ios (1.5.1).

sgerardi commented 5 years ago

@kyuss Has there been any progress on this? My app relies on the Filestack-swift repository which has this as a dependency.

benRivello commented 5 years ago

The workaround provided by @sgerardi in filestack-swift/issues/13 worked for me.

rnine commented 5 years ago

Fixed in develop branch.