[__NSCFConstantString matchesRegularExpression:]: unrecognized selector sent to instance xxx
is thrown after I manually integrate the SDK and set regionName
for the QCloudCOSXMLEndPoint
instance?Cause: matchesRegularExpression
is a method in the NSString
category. Objective-C does not define linker symbols for each method, but for each class. The SDK is a static library. If a category has been defined for an existing class in the static library, the system assumes that the class already exists and will not integrate the code of the class and category. As a result, methods in the category will be missing in the executable code.
Solution:
-Objc
and -all_load
parameters.-ObjC
loads the classes and categories in the static library to the executable file. If there are only categories but no classes in the library, -ObjC
will not take effect. In this case, -all_load
is needed to load all object files to the executable file.Default OCR configuration is not set/Key is not set to 'xxx' in the OCR configuration. Please call this method after it is configured
is thrown after I integrated the SDK and sent a request?Cause: All SDK requests depend on QCloudCOSXMLService
and QCloudCOSTransferMangerService
(advanced upload APIs depend on this instance). If the corresponding service is not registered before the request is sent, this error will be thrown.
Solution: Use the following code to register the service instance required by the request. Ensure that the instance exists before you send a request.
QCloudServiceConfiguration *configuration = [QCloudServiceConfiguration new];
configuration.appID = "AppId";
configuration.signatureProvider = self;
QCloudCOSXMLEndPoint *endpoint = [[QCloudCOSXMLEndPoint alloc] init];
endpoint.regionName = @"region";
endpoint.useHTTPS = YES;
configuration.endpoint = endpoint;
[QCloudCOSXMLService registerDefaultCOSXMLWithConfiguration:configuration];
[QCloudCOSTransferMangerService registerDefaultCOSTransferMangerWithConfiguration:configuration];
Default COSXMLService already exists. To use new configurations, re-register using registerCOSXMLWithConfiguration:withKey:
is thrown after I integrated the SDK?Cause: In the SDK, different COSXMLService
instances correspond to different configurations (for the configurations, please see relevant attributes). For example, setting regionName
to guangzhou
and beijing
indicates two different configurations, where two services need to be registered. If you already used ap-guangzhou
to register a service and then set region
to ap-guangzhou
to register again, this error will occur.
Solution:
registerDefaultCOSXMLWithConfiguration:
and the key does not need to be specified.// Determine whether the key to register exists.
if(![QCloudCOSXMLService hasServiceForKey:@"Key to register"]){
// If the key does not exist, register a new service.
[QCloudCOSXMLService registerCOSXMLWithConfiguration:configuration withKey:@"Key to register"]
}
- (void)signatureWithFields:(QCloudSignatureFields *)fileds request:urlRequest:compelete:
proxy is not called after I run the SDK?Cause: This proxy method obtains the key/signature. To give full play to the key validity (calling the signature earlier will cause it to expire sooner), the SDK calls the key only before the request is sent ([task resume]
).
Solution:
signatureProvider
is configured (for example, configured as configuration.signatureProvider = self
, in which self
is the class where the proxy method belongs) after the QCloudServiceConfiguration
instance is created.The SDK provides QCloudCredentailFenceQueue
to cache or reuse the key. For more information, please see Getting Started.
QCloudCOSXMLUploadObjectRequest
throws the error Body of this type is not supported. Supported types are NSData, QCloudFileOffsetBody, and NSURL
?Currently, the SDK supports the following three types of bodies:
QCloudCOSXMLUploadObjectRequest
to upload videos or files from the system photo library, but checkpoint restart fails, throwing the error The specified Content-Length is zero
?The SDK supports checkpoint restart only for files in the sandbox. To use the checkpoint restart feature, move your files to the sandbox first.
Ensure that the local file is not modified after you set the body. For example, if the upload API is called when the file is still being compressed or file write is not completed yet, the SDK will upload the file (using multipart upload) according to the size at the time of upload, causing a file size inconsistency between the COS file and the local file.
Solution:
Ensure that the URL starts with “file://”. You can initialize in either of the following two ways:
Solution:
file:///var/mobile/Media/DCIM/101APPLE/
cannot be accessed directly. Photos in this path can only be obtained using the request method in the Photos framework.[[PHImageManager defaultManager] requestPlayerItemForVideo:asset options:option resultHandler:^(AVPlayerItem *playerItem, NSDictionary *info) {
// Move the file to the sandbox in time or save the playerItem.
}];
method to save the obtained playerItem
, or move the desired files to the App Sandbox during the callback. The cause of this error is that for iOS11, when playerItem
is released, read permission on the file specified in playerItem
will expire, making the size of the uploaded file 0.tmp
directory (e.g., /var/mobile/Containers/Data/Application/0BFBB3FE-0FD0-46CB-ADDE-DDE08F6D62C3/tmp/
). Files in tmp
will be cleared by the system any time. You can move your files to a securer directory in case they are cleared during the upload. For more information about sandbox, please see File System Basics.The MD5 checksum is inconsistent with the local file. Please check whether the file is modified during the upload. During multipart uploads, the MD5 checksum of each uploaded part will be verified against the local file. Any inconsistency will cause an error
is reported?Cause: If you use the SDK to upload a file greater than 1 MB, the file will be divided into multiple 1-MB parts and uploaded using multipart upload. After all parts are uploaded, the value of the backend-returned ETag
will be compared with that of local parts. If there is any inconsistency, this error will be thrown.
Solution: Check whether the file is modified during the upload.
Solution: SDK 5.7.0 and later versions support customizing request timeout as follows:
QCloudServiceConfiguration *config = [QCloudServiceConfiguration new]
.timeoutInterval
attribute of config
, for example, .timeoutInterval = 30;
.Check whether you are using the latest version. If not, you are advised to update to the latest SDK version. For the latest iOS SDK, please see qcloud-sdk-ios.
Apakah halaman ini membantu?