|
|
@@ -23,6 +23,8 @@
|
|
|
|
|
|
@property (nonatomic, strong) OSSGetObjectRequest *normalDloadRequest;
|
|
|
|
|
|
+@property (nonatomic, strong) NSDateFormatter *formatter;
|
|
|
+@property (nonatomic, copy) NSString *month;
|
|
|
@end
|
|
|
|
|
|
|
|
|
@@ -155,7 +157,7 @@
|
|
|
NSLog(@"objectKey:%@",objectKey);
|
|
|
_normalUploadRequest = [OSSPutObjectRequest new];
|
|
|
_normalUploadRequest.bucketName = self.OSSInfo[@"bucket"];
|
|
|
- _normalUploadRequest.objectKey = objectKey;
|
|
|
+ _normalUploadRequest.objectKey = [self formatObjectKeyWith:objectKey];
|
|
|
_normalUploadRequest.uploadingFileURL = [NSURL fileURLWithPath:filePath];
|
|
|
_normalUploadRequest.isAuthenticationRequired = YES;
|
|
|
weakSelf(self);
|
|
|
@@ -249,7 +251,7 @@
|
|
|
OSSResumableUploadRequest * resumableUpload = [OSSResumableUploadRequest new];
|
|
|
resumableUpload.bucketName = self.OSSInfo[@"bucket"];
|
|
|
// objectKey等同于objectName,表示断点上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg
|
|
|
- resumableUpload.objectKey = objectKey;
|
|
|
+ resumableUpload.objectKey = [self formatObjectKeyWith:objectKey];
|
|
|
resumableUpload.partSize = 1024 * 1024;
|
|
|
resumableUpload.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
|
|
|
// NSLog(@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
|
|
|
@@ -393,7 +395,7 @@
|
|
|
if([state isEqualToString:@"2"]){
|
|
|
NSString *localPath =extend[@"localurl"];
|
|
|
NSURL *loaclUrl = [NSURL URLWithString:localPath];
|
|
|
- NSString *url = [NSString stringWithFormat:@"http://oss.abtim-my.com/%@",loaclUrl.lastPathComponent];
|
|
|
+ NSString *url = [self fullUploadURLByAppendPath:loaclUrl.lastPathComponent];
|
|
|
[mextend setObject:url forKey:@"url"];
|
|
|
[mextend setObject:[NSNumber numberWithInt:0] forKey:@"fileError"];
|
|
|
[mmsg setObject:mextend forKey:@"extend"];
|
|
|
@@ -456,6 +458,27 @@
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+- (NSString *)fullUploadURLByAppendPath:(NSString *)path {
|
|
|
+ return [NSString stringWithFormat:@"http://oss.abtim-my.com/%@/%@", self.month, path];
|
|
|
+}
|
|
|
+
|
|
|
+- (NSDateFormatter *)formatter {
|
|
|
+ if (!_formatter) {
|
|
|
+ _formatter = [[NSDateFormatter alloc] init];
|
|
|
+ [_formatter setDateFormat:@"yyyy-MM"]; // 设置你想要的日期格式
|
|
|
+ }
|
|
|
+ return _formatter;
|
|
|
+}
|
|
|
|
|
|
+- (NSString *)month {
|
|
|
+ if (!_month) {
|
|
|
+ _month = [self.formatter stringFromDate:[NSDate date]];
|
|
|
+ }
|
|
|
+ return _month;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSString *)formatObjectKeyWith:(NSString *)objectKey {
|
|
|
+ return [NSString stringWithFormat:@"%@/%@", self.month, objectKey];;
|
|
|
+}
|
|
|
|
|
|
@end
|