Skip to content

Commit 0e911b2

Browse files
committed
optimize PHAsset export file
1 parent 6999cb4 commit 0e911b2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

QiniuSDK.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,7 @@
13221322
};
13231323
DF2CDE2319DAC08400CE01FB = {
13241324
CreatedOnToolsVersion = 6.0.1;
1325+
DevelopmentTeam = 5G98NLC322;
13251326
};
13261327
};
13271328
};
@@ -1885,6 +1886,7 @@
18851886
baseConfigurationReference = 6DD894AA2A19370381AD4201 /* Pods-QiniuSDK_iOSTests.debug.xcconfig */;
18861887
buildSettings = {
18871888
COPY_PHASE_STRIP = NO;
1889+
DEVELOPMENT_TEAM = 5G98NLC322;
18881890
GCC_DYNAMIC_NO_PIC = NO;
18891891
GCC_OPTIMIZATION_LEVEL = 0;
18901892
PRODUCT_NAME = QiniuSDK_iOSTests;
@@ -1898,6 +1900,7 @@
18981900
buildSettings = {
18991901
COPY_PHASE_STRIP = YES;
19001902
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1903+
DEVELOPMENT_TEAM = 5G98NLC322;
19011904
PRODUCT_NAME = QiniuSDK_iOSTests;
19021905
SDKROOT = iphoneos;
19031906
};

QiniuSDK/Utils/QNPHAssetFile.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ - (void)exportAssert {
212212
resource = assetRes;
213213
}
214214
}
215-
NSString *fileName = [NSString stringWithFormat:@"tempAsset-%@.mov", [NSDate date]];
216-
if (resource.originalFilename) {
217-
fileName = resource.originalFilename;
218-
}
215+
NSString *fileName = [NSString stringWithFormat:@"tempAsset-%f-%d.mov", [[NSDate date] timeIntervalSince1970], arc4random()%100000];
219216
PHAssetResourceRequestOptions *options = [PHAssetResourceRequestOptions new];
220217
//不支持icloud上传
221218
options.networkAccessAllowed = NO;

QiniuSDK/Utils/QNPHAssetResource.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ - (void)getInfo {
105105
_hasGotInfo = YES;
106106
NSConditionLock *assetReadLock = [[NSConditionLock alloc] initWithCondition:kAMASSETMETADATA_PENDINGREADS];
107107

108-
NSString *pathToWrite = [NSTemporaryDirectory() stringByAppendingString:self.phAssetResource.originalFilename];
108+
NSString *fileName = [NSString stringWithFormat:@"tempAsset-%f-%d.mov", [[NSDate date] timeIntervalSince1970], arc4random()%100000];
109+
NSString *pathToWrite = [NSTemporaryDirectory() stringByAppendingString:fileName];
109110
NSURL *localpath = [NSURL fileURLWithPath:pathToWrite];
110111
PHAssetResourceRequestOptions *options = [PHAssetResourceRequestOptions new];
111112
options.networkAccessAllowed = YES;
@@ -143,7 +144,8 @@ - (NSData *)fetchDataFromAsset:(PHAssetResource *)videoResource error:(NSError *
143144

144145
NSConditionLock *assetReadLock = [[NSConditionLock alloc] initWithCondition:kAMASSETMETADATA_PENDINGREADS];
145146

146-
NSString *pathToWrite = [NSTemporaryDirectory() stringByAppendingString:videoResource.originalFilename];
147+
NSString *fileName = [NSString stringWithFormat:@"tempAsset-%f-%d.mov", [[NSDate date] timeIntervalSince1970], arc4random()%100000];
148+
NSString *pathToWrite = [NSTemporaryDirectory() stringByAppendingString:fileName];
147149
NSURL *localpath = [NSURL fileURLWithPath:pathToWrite];
148150
PHAssetResourceRequestOptions *options = [PHAssetResourceRequestOptions new];
149151
options.networkAccessAllowed = YES;

0 commit comments

Comments
 (0)