Problem description
When you use the iOS SDK to upload a resource to OSS, the upload appears successful, but the resource cannot be found in the OSS console.
Problem cause
Uploading large files over a wireless network can be time-consuming. If the upload is interrupted by poor network conditions or a network switch, the entire file must be re-uploaded.
Solutions
You can use the following methods to optimize the upload operation.
Resumable upload
To mitigate issues caused by network instability, use the resumable upload feature to upload resources. For more information, see Resumable Upload.
Set the network timeout period and number of retries
You can set the network timeout period and number of retries on the client by editing the following code in the iOS SDK.
OSSClientConfiguration * conf = [OSSClientConfiguration new];
conf.maxRetryCount = 3; // The number of retries after a network request fails.
conf.timeoutIntervalForRequest = 30; // The timeout period for a network request.
Set Content-Type and MD5
Set the Content-Type and enable MD5 validation. If the validation fails, re-upload the resource.
Verify the crc64 value
Data transmission errors can occur between the client and the server. For objects uploaded by any method, OSS can return a crc64 value. The client can then compare this value with a locally calculated crc64 value to verify data integrity. For more information, see CRC64 Check.
Enable logging
-
Enable the OSS logging feature to help you diagnose problems that occur during resource uploads.
-
The mobile client environment is complex, and the OSS SDK may not function correctly in all regions or at all times. To help developers diagnose these issues, the OSS SDK can record logs locally. Before using the OSS client, initialize it and call the method to enable logging. When logging is enabled:
-
You can store files in the sandbox's Caches folder or the OSSLogs folder.
-
You can optionally upload the files to a server for further troubleshooting.
-