feat:修改七牛云上传下载路径读取 qiniudomain文件夹下的子文件夹名称
This commit is contained in:
@@ -1269,11 +1269,22 @@ FuncPublic * _funcPublic = nil;
|
||||
+(NSString *)filename:(NSString *)file
|
||||
{
|
||||
NSString *path=[FuncPublic getFilePath:file PathType:3];// 要列出来的目录
|
||||
// NSLog(@"[FuncPublic filename] reading path: %@", path);
|
||||
|
||||
NSFileManager* fm=[NSFileManager defaultManager];
|
||||
if([fm fileExistsAtPath:path]){
|
||||
NSArray *files = [fm subpathsAtPath: path ];
|
||||
NSLog(@"%@",[files objectAtIndex:0]);
|
||||
return [files objectAtIndex:0];
|
||||
NSArray *files = [fm subpathsAtPath: path];
|
||||
// NSLog(@"[FuncPublic filename] files found in %@: %@", file, files);
|
||||
|
||||
for (NSString *name in files) {
|
||||
// 过滤隐藏文件和 .DS_Store
|
||||
if (![name hasPrefix:@"."] && ![name isEqualToString:@".DS_Store"]) {
|
||||
// NSLog(@"[FuncPublic filename] filename found: %@", name);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// NSLog(@"[FuncPublic filename] Path does not exist: %@", path);
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#import "gameController.h"
|
||||
#import <CoreTelephony/CTCall.h>
|
||||
#import <CoreTelephony/CTCallCenter.h>
|
||||
#import "QiniuManager.h"
|
||||
#import <CoreTelephony/CTCarrier.h>
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
#import "AppDelegate.h"
|
||||
@@ -1886,6 +1887,29 @@
|
||||
}
|
||||
NSString *amrPath = [FuncPublic GetPathByFileName: _fileName ofType:@"amr"];
|
||||
if ([VoiceConverter ConvertWavToAmr:_filePath amrSavePath:amrPath]){
|
||||
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.dateFormat =@"yyyyMMddHHmmss";
|
||||
NSString *str = [formatter stringFromDate:[NSDate date]];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%08X.amr", str, arc4random()];
|
||||
|
||||
// 使用七牛云上传
|
||||
[[QiniuManager sharedManager] uploadAudioFile:amrPath
|
||||
fileName:fileName
|
||||
progressHandler:^(float percent) {
|
||||
NSLog(@"七牛上传进度: %.2f", percent);
|
||||
} completionHandler:^(NSString *key, NSError *error) {
|
||||
if (error) {
|
||||
NSLog(@"七牛上传失败: %@", error);
|
||||
} else {
|
||||
NSLog(@"七牛上传成功, key: %@", key);
|
||||
// 获取完整URL
|
||||
NSString *audiourl = [[QiniuManager sharedManager] getFileUrlWithKey:key];
|
||||
|
||||
[_bridge callHandler:@"getaudiourl" data:@{ @"audiourl":audiourl,@"time":[NSString stringWithFormat:@"%ld",(long)time]} ];
|
||||
}
|
||||
}];
|
||||
/*
|
||||
NSData *test=[NSData dataWithContentsOfFile:amrPath];
|
||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||
//接收类型不一致请替换一致text/html或别的
|
||||
@@ -1895,7 +1919,7 @@
|
||||
@"image/png",
|
||||
@"application/octet-stream",
|
||||
@"text/json",
|
||||
@"audio/amr",
|
||||
@"audio/amr",
|
||||
nil];
|
||||
NSString *string=@"http://gameapi.0791ts.cn/api/UpLoad/PostFile";
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
@@ -1915,6 +1939,7 @@
|
||||
} failure:^(NSURLSessionDataTask *_Nullable task, NSError * _Nonnull error) {
|
||||
NSLog(@"上传失败");
|
||||
}];
|
||||
*/
|
||||
}else
|
||||
NSLog(@"wav转amr失败");
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ extern NSString *const kQiniuSecretKey;
|
||||
extern NSString *const kQiniuBucketName;
|
||||
|
||||
// 七牛云默认域名
|
||||
extern NSString *const kQiniuDomain;
|
||||
extern NSString *kQiniuDomain;
|
||||
|
||||
// 录音文件目录
|
||||
extern NSString *const kQiniuRecordingDirectory;
|
||||
|
||||
@@ -16,7 +16,7 @@ NSString *const kQiniuSecretKey = @"RCZpwLhAPoQ2sQQyWXzMJc7Po2MyZWfUJeW4Jmfq";
|
||||
NSString *const kQiniuBucketName = @"iosaudio";
|
||||
|
||||
// 七牛云默认域名,用于访问上传后的文件
|
||||
NSString *const kQiniuDomain = @"iosaudio.daoqi88.cn";
|
||||
NSString *kQiniuDomain = @"iosaudio.daoqi8888.cn";
|
||||
|
||||
// 录音文件在七牛云中的目录
|
||||
NSString *const kQiniuRecordingDirectory = @"";
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import <objc/runtime.h>
|
||||
#import <CommonCrypto/CommonHMAC.h>
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#import "FuncPublic.h"
|
||||
|
||||
@implementation QiniuManager
|
||||
|
||||
@@ -192,7 +193,8 @@
|
||||
}
|
||||
|
||||
- (NSString *)getFileUrlWithKey:(NSString *)key {
|
||||
return [NSString stringWithFormat:@"%@/%@", kQiniuDomain, key];
|
||||
// 域名已在AppDelegate启动时从文件夹读取并赋值给kQiniuDomain
|
||||
return [NSString stringWithFormat:@"http://%@/%@", kQiniuDomain, key];
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods
|
||||
|
||||
Reference in New Issue
Block a user