We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我想设置上传后在阿里云盘的路径,设置成 folderId: "root/test", 就报错了 NetworkSystemError ▿ httpError : 3 elements - statusCode : 400 ▿ data : 256 bytes - count : 256 ▿ pointer : 0x0000000111bfd146 - pointerValue : 4592750918 - response : <NSHTTPURLResponse: 0x281f03820> { URL: https://openapi.alipan.com/adrive/v1.0/openFile/create } { Status Code: 400, Headers { "Content-Length" = ( 256 ); "Content-Type" = ( "application/json" ); Date = ( "Tue, 15 Oct 2024 05:25:21 GMT" ); Server = ( "istio-envoy" ); Vary = ( "Origin,Access-Control-Request-Method,Access-Control-Request-Headers" ); "req-arrive-time" = ( 1728969921587 ); "req-cost-time" = ( 72 ); "resp-start-time" = ( 1728969921660 ); "x-canary" = ( "product=adrive,uid=d0cda0dc2f804745a6687bd082c86510" ); "x-envoy-upstream-service-time" = ( 60 ); "x-request-id" = ( "c6e29d84-855c-4c87-b04f-268261364242, 0a00701217289699215828419ee9a0" ); } }
下面是我代码 @objc public func uploadFile(withURL url: URL, fileName:String,completion: @escaping (String, NSError?) -> Void) { Task { do { let driveInfo = try await client .authorize() .send(AliyunpanScope.User.GetDriveInfo())
let driveId = driveInfo.default_drive_id let file = try await client.uploader .upload( fileURL: url, fileName: fileName, driveId: driveId, folderId: "root/test", useProof: false) completion(file.description, nil) } catch { completion("", error as NSError) } } }
The text was updated successfully, but these errors were encountered:
已解决需要自己手动创建文件夹
private func findOrCreateFolder(driveId: String, parentFileId: String) async throws -> String { // 创建获取文件列表的请求 let request = AliyunpanFileScope.GetFileList.Request( drive_id: driveId, parent_file_id: parentFileId, limit: 100, type: .folder ) let getFileListCommand = AliyunpanFileScope.GetFileList(request) // 获取文件列表 let response = try await client.authorize().send(getFileListCommand) // 查找指定文件夹 for file in response.items { if file.name == "test" { return file.file_id // 如果找到,返回文件夹 ID } } // 如果没有找到,创建文件夹 let createFolderRequest = AliyunpanFileScope.CreateFile.Request( drive_id: driveId, parent_file_id: parentFileId, name: "test", type: .folder, check_name_mode: .ignore ) let createFolderCommand = AliyunpanFileScope.CreateFile(createFolderRequest) let createFolderResponse = try await client.authorize().send(createFolderCommand) return createFolderResponse.file_id // 返回新创建的文件夹 ID }
Sorry, something went wrong.
No branches or pull requests
我想设置上传后在阿里云盘的路径,设置成 folderId: "root/test", 就报错了
NetworkSystemError
▿ httpError : 3 elements
- statusCode : 400
▿ data : 256 bytes
- count : 256
▿ pointer : 0x0000000111bfd146
- pointerValue : 4592750918
- response : <NSHTTPURLResponse: 0x281f03820> { URL: https://openapi.alipan.com/adrive/v1.0/openFile/create } { Status Code: 400, Headers {
"Content-Length" = (
256
);
"Content-Type" = (
"application/json"
);
Date = (
"Tue, 15 Oct 2024 05:25:21 GMT"
);
Server = (
"istio-envoy"
);
Vary = (
"Origin,Access-Control-Request-Method,Access-Control-Request-Headers"
);
"req-arrive-time" = (
1728969921587
);
"req-cost-time" = (
72
);
"resp-start-time" = (
1728969921660
);
"x-canary" = (
"product=adrive,uid=d0cda0dc2f804745a6687bd082c86510"
);
"x-envoy-upstream-service-time" = (
60
);
"x-request-id" = (
"c6e29d84-855c-4c87-b04f-268261364242, 0a00701217289699215828419ee9a0"
);
} }
下面是我代码
@objc public func uploadFile(withURL url: URL, fileName:String,completion: @escaping (String, NSError?) -> Void) {
Task {
do {
let driveInfo = try await client
.authorize()
.send(AliyunpanScope.User.GetDriveInfo())
The text was updated successfully, but these errors were encountered: