Skip to content

Commit fb03f90

Browse files
authored
Merge pull request #393 from YangSen-qn/develop
Support InputStream
2 parents 430ea6d + 24a8c93 commit fb03f90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3328
-1652
lines changed

QiniuDemo/QiniuDemo.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
31304CA325628E97001034D2 /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = 31304CA025628E97001034D2 /* image.png */; };
1313
31304CA425628E97001034D2 /* UploadResource_49M.zip in Resources */ = {isa = PBXBuildFile; fileRef = 31304CA125628E97001034D2 /* UploadResource_49M.zip */; };
1414
31304CA525628E97001034D2 /* image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 31304CA225628E97001034D2 /* image.jpg */; };
15+
3152B913268C4EC3004705AA /* UploadResource_1.44G.zip in Resources */ = {isa = PBXBuildFile; fileRef = 3152B912268C4EC3004705AA /* UploadResource_1.44G.zip */; };
1516
318191AB2531516F00D18536 /* UploadResource.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 318191AA2531516F00D18536 /* UploadResource.dmg */; };
1617
93D230241C86D7F700434F6D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D230231C86D7F700434F6D /* main.m */; };
1718
93D230271C86D7F700434F6D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D230261C86D7F700434F6D /* AppDelegate.m */; };
@@ -46,8 +47,10 @@
4647
31304CA025628E97001034D2 /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = "<group>"; };
4748
31304CA125628E97001034D2 /* UploadResource_49M.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = UploadResource_49M.zip; sourceTree = "<group>"; };
4849
31304CA225628E97001034D2 /* image.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = image.jpg; sourceTree = "<group>"; };
50+
3152B912268C4EC3004705AA /* UploadResource_1.44G.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = UploadResource_1.44G.zip; sourceTree = "<group>"; };
4951
318191AA2531516F00D18536 /* UploadResource.dmg */ = {isa = PBXFileReference; lastKnownFileType = file; path = UploadResource.dmg; sourceTree = "<group>"; };
5052
318191AF25315F3500D18536 /* Configure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Configure.h; sourceTree = "<group>"; };
53+
3189882026469145003CCA68 /* QiniuDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = QiniuDemo.entitlements; sourceTree = "<group>"; };
5154
6B9BC5A8D93F988C1240E05F /* libPods-QiniuDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-QiniuDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
5255
93D2301F1C86D7F700434F6D /* QiniuDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QiniuDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
5356
93D230231C86D7F700434F6D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -100,6 +103,7 @@
100103
318191A92531516F00D18536 /* DemoTestResource */ = {
101104
isa = PBXGroup;
102105
children = (
106+
3152B912268C4EC3004705AA /* UploadResource_1.44G.zip */,
103107
31304CA225628E97001034D2 /* image.jpg */,
104108
31304CA025628E97001034D2 /* image.png */,
105109
31304CA125628E97001034D2 /* UploadResource_49M.zip */,
@@ -154,6 +158,7 @@
154158
93D230211C86D7F700434F6D /* QiniuDemo */ = {
155159
isa = PBXGroup;
156160
children = (
161+
3189882026469145003CCA68 /* QiniuDemo.entitlements */,
157162
318191A92531516F00D18536 /* DemoTestResource */,
158163
93D230251C86D7F700434F6D /* AppDelegate.h */,
159164
93D230261C86D7F700434F6D /* AppDelegate.m */,
@@ -303,6 +308,7 @@
303308
93D230321C86D7F700434F6D /* LaunchScreen.storyboard in Resources */,
304309
318191AB2531516F00D18536 /* UploadResource.dmg in Resources */,
305310
93D2302F1C86D7F700434F6D /* Assets.xcassets in Resources */,
311+
3152B913268C4EC3004705AA /* UploadResource_1.44G.zip in Resources */,
306312
93D2302D1C86D7F700434F6D /* Main.storyboard in Resources */,
307313
31304CA525628E97001034D2 /* image.jpg in Resources */,
308314
31304CA325628E97001034D2 /* image.png in Resources */,
@@ -536,12 +542,14 @@
536542
baseConfigurationReference = F90FEC5E40BE695E8AA6A8A7 /* Pods-QiniuDemo.debug.xcconfig */;
537543
buildSettings = {
538544
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
545+
CODE_SIGN_ENTITLEMENTS = QiniuDemo/QiniuDemo.entitlements;
539546
DEVELOPMENT_TEAM = W2TP34G2MM;
540547
INFOPLIST_FILE = QiniuDemo/Info.plist;
541548
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
542549
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
543550
PRODUCT_BUNDLE_IDENTIFIER = com.qiniu.QiniuDemo;
544551
PRODUCT_NAME = "$(TARGET_NAME)";
552+
SUPPORTS_MACCATALYST = YES;
545553
};
546554
name = Debug;
547555
};
@@ -550,12 +558,14 @@
550558
baseConfigurationReference = 24EE530BBB100BED89B08A3D /* Pods-QiniuDemo.release.xcconfig */;
551559
buildSettings = {
552560
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
561+
CODE_SIGN_ENTITLEMENTS = QiniuDemo/QiniuDemo.entitlements;
553562
DEVELOPMENT_TEAM = W2TP34G2MM;
554563
INFOPLIST_FILE = QiniuDemo/Info.plist;
555564
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
556565
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
557566
PRODUCT_BUNDLE_IDENTIFIER = com.qiniu.QiniuDemo;
558567
PRODUCT_NAME = "$(TARGET_NAME)";
568+
SUPPORTS_MACCATALYST = YES;
559569
};
560570
name = Release;
561571
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.personal-information.photos-library</key>
6+
<true/>
7+
</dict>
8+
</plist>

QiniuDemo/QiniuDemo/ViewController.m

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "Configure.h" // 测试参数配置,暂时只有token,可删除
1010
#import "ViewController.h"
1111
#import "QNTransactionManager.h"
12+
#import <Photos/Photos.h>
1213

1314
typedef NS_ENUM(NSInteger, UploadState){
1415
UploadStatePrepare,
@@ -48,8 +49,14 @@ - (IBAction)uploadAction:(UIButton *)sender {
4849
if (self.uploadState == UploadStatePrepare) {
4950

5051
#ifdef YourToken
51-
// NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource.dmg" ofType:nil];
52-
NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource_49M.zip" ofType:nil];
52+
NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource.dmg" ofType:nil];
53+
path = [[NSBundle mainBundle] pathForResource:@"UploadResource_49M.zip" ofType:nil];
54+
path = [[NSBundle mainBundle] pathForResource:@"UploadResource_1.44G.zip" ofType:nil];
55+
56+
// NSFileManager *manager = [NSFileManager defaultManager];
57+
// NSURL *desktopUrl = [manager URLsForDirectory:NSDesktopDirectory inDomains:NSUserDomainMask].firstObject;
58+
// path = [desktopUrl URLByAppendingPathComponent:@"pycharm.dmg"].path;
59+
5360
[self uploadImageToQNFilePath:path];
5461
[self changeUploadState:UploadStateUploading];
5562
#else
@@ -85,8 +92,8 @@ - (void)uploadImageToQNFilePath:(NSString *)filePath {
8592

8693
self.token = YourToken;
8794
QNConfiguration *configuration = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
88-
builder.useConcurrentResumeUpload = YES;
89-
builder.resumeUploadVersion = QNResumeUploadVersionV2;
95+
builder.useConcurrentResumeUpload = NO;
96+
builder.resumeUploadVersion = QNResumeUploadVersionV1;
9097
builder.recorder = [QNFileRecorder fileRecorderWithFolder:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] error:nil];
9198
}];
9299
QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:configuration];
@@ -102,14 +109,36 @@ - (void)uploadImageToQNFilePath:(NSString *)filePath {
102109
return weakSelf.uploadState == UploadStateCancelling;
103110
}];
104111

105-
[upManager putFile:filePath key:@"DemoResource" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
112+
// [upManager putFile:filePath key:@"DemoResource" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
113+
// NSLog(@"info ===== %@", info);
114+
// NSLog(@"resp ===== %@", resp);
115+
//
116+
// [weakSelf changeUploadState:UploadStatePrepare];
117+
// [weakSelf alertMessage:info.message];
118+
// }
119+
// option:uploadOption];
120+
121+
long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil] fileSize];
122+
NSInputStream *stream = [NSInputStream inputStreamWithFileAtPath:filePath];
123+
[upManager putInputStream:stream sourceId:filePath.lastPathComponent size:fileSize fileName:filePath.lastPathComponent key:@"DemoResource_1.44G" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
106124
NSLog(@"info ===== %@", info);
107125
NSLog(@"resp ===== %@", resp);
108-
126+
109127
[weakSelf changeUploadState:UploadStatePrepare];
110128
[weakSelf alertMessage:info.message];
111-
}
112-
option:uploadOption];
129+
} option:uploadOption];
130+
131+
// NSURL *url = [NSURL fileURLWithPath:filePath];
132+
// PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
133+
// PHAsset *asset = fetchResult.firstObject;
134+
// [upManager putPHAsset:asset key:@"DemoResource" token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
135+
// NSLog(@"info ===== %@", info);
136+
// NSLog(@"resp ===== %@", resp);
137+
//
138+
// [weakSelf changeUploadState:UploadStatePrepare];
139+
// [weakSelf alertMessage:info.message];
140+
// }
141+
// option:uploadOption];
113142
}
114143

115144
- (void)gotoImageLibrary {

QiniuDemoOC/QiniuDemo.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)