Filestack iOS 上传图片时出现 400 错误 "Parameters are invalid"
Filestack iOS getting 400 error "Parameters are invalid" on the image upload
我正在尝试在 React Native 项目中使用 Filestack iOS SDK。所以我从 JavaScript 传递本地文件 URL 并使用以下代码上传图像
@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)
}
}
我正在获取进度数据,所以我想图像正在上传。但是出现错误 - aborted
这是 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" = (
xxxxxxxxxxxxxx
);
} }), json: Optional(["i": , "c": {
ujid = "c916857b-0a22-4305-9324-6f1055b610f2";
"ujid_path" = "ul-0";
}, "error": Parameters are invalid, "t": 1544721095]), error: nil)
我做错了什么吗?
以下拉取请求 https://github.com/filestack/filestack-swift/pull/12 解决了我的问题。
我正在尝试在 React Native 项目中使用 Filestack iOS SDK。所以我从 JavaScript 传递本地文件 URL 并使用以下代码上传图像
@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)
}
}
我正在获取进度数据,所以我想图像正在上传。但是出现错误 - aborted
这是 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" = (
xxxxxxxxxxxxxx
);
} }), json: Optional(["i": , "c": {
ujid = "c916857b-0a22-4305-9324-6f1055b610f2";
"ujid_path" = "ul-0";
}, "error": Parameters are invalid, "t": 1544721095]), error: nil)
我做错了什么吗?
以下拉取请求 https://github.com/filestack/filestack-swift/pull/12 解决了我的问题。