Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gee1k committed Oct 2, 2020
2 parents 42053b0 + 1f8e88c commit 2af73ae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
20 changes: 11 additions & 9 deletions uPic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1030;
LastUpgradeCheck = 1110;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = "Svend Jin";
TargetAttributes = {
16A6DC5322AA375700813706 = {
Expand Down Expand Up @@ -1146,6 +1146,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -1208,6 +1209,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -1247,7 +1249,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 20200814;
CURRENT_PROJECT_VERSION = 20201002;
DEVELOPMENT_TEAM = W863J6W8DZ;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist";
Expand All @@ -1256,7 +1258,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.20.0;
MARKETING_VERSION = 0.20.1;
PRODUCT_BUNDLE_IDENTIFIER = com.svend.uPic;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1277,7 +1279,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 20200814;
CURRENT_PROJECT_VERSION = 20201002;
DEVELOPMENT_TEAM = W863J6W8DZ;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist";
Expand All @@ -1286,7 +1288,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.20.0;
MARKETING_VERSION = 0.20.1;
PRODUCT_BUNDLE_IDENTIFIER = com.svend.uPic;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1303,7 +1305,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 20200814;
CURRENT_PROJECT_VERSION = 20201002;
DEVELOPMENT_TEAM = W863J6W8DZ;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = uPicFinderExtension/Info.plist;
Expand All @@ -1313,7 +1315,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.20.0;
MARKETING_VERSION = 0.20.1;
PRODUCT_BUNDLE_IDENTIFIER = com.svend.uPic.uPicFinderExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1330,7 +1332,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 20200814;
CURRENT_PROJECT_VERSION = 20201002;
DEVELOPMENT_TEAM = W863J6W8DZ;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = uPicFinderExtension/Info.plist;
Expand All @@ -1340,7 +1342,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 0.20.0;
MARKETING_VERSION = 0.20.1;
PRODUCT_BUNDLE_IDENTIFIER = com.svend.uPic.uPicFinderExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion uPic.xcodeproj/xcshareddata/xcschemes/uPic.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
21 changes: 16 additions & 5 deletions uPic/Models/BaseUploader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import Alamofire
class BaseUploader {

func start() {
(NSApplication.shared.delegate as? AppDelegate)?.uploadStart()
DispatchQueue.main.async {
(NSApplication.shared.delegate as? AppDelegate)?.uploadStart()
}
}

func progress(percent: Double) {
(NSApplication.shared.delegate as? AppDelegate)?.uploadProgress(percent: percent)
DispatchQueue.main.async {
(NSApplication.shared.delegate as? AppDelegate)?.uploadProgress(percent: percent)
}
}

func completed(url: String, _ fileData: Data?, _ fileUrl: URL?, _ fileName: String?) {
Expand Down Expand Up @@ -72,11 +76,16 @@ class BaseUploader {

ConfigManager.shared.addHistory(previewModel)
}
(NSApplication.shared.delegate as? AppDelegate)?.uploadCompleted(url: url)

DispatchQueue.main.async {
(NSApplication.shared.delegate as? AppDelegate)?.uploadCompleted(url: url)
}
}

func faild(errorMsg: String? = "") {
(NSApplication.shared.delegate as? AppDelegate)?.uploadFaild(errorMsg: errorMsg)
DispatchQueue.main.async {
(NSApplication.shared.delegate as? AppDelegate)?.uploadFaild(errorMsg: errorMsg)
}
}

/*********************************************************** static *******************************************************************/
Expand Down Expand Up @@ -169,7 +178,9 @@ class BaseUploader {
if (!BaseUploader.checkFileSize(fileSize: UInt64(data.count), limitSize: limitSize)) {

let errorMsg = "\("File is over the size limit! Limit:".localized)\(ByteCountFormatter.string(fromByteCount: Int64(limitSize), countStyle: .binary))"
(NSApplication.shared.delegate as? AppDelegate)?.uploadFaild(errorMsg: errorMsg)
DispatchQueue.main.async {
(NSApplication.shared.delegate as? AppDelegate)?.uploadFaild(errorMsg: errorMsg)
}
return
}

Expand Down
6 changes: 3 additions & 3 deletions uPic/Models/S3/S3Uploader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import Foundation
import AWSSDKSwiftCore
import S3
import NIO
import NIOHTTP1


class S3Uploader: BaseUploader {
Expand Down Expand Up @@ -67,7 +65,9 @@ class S3Uploader: BaseUploader {

let suffix = BaseUploaderUtil._parseVariables(config.suffix, fileName, otherVariables: nil)

let s3 = S3(accessKeyId: accessKey, secretAccessKey: secretKey, region: region, endpoint: S3Util.computedS3Endpoint(endpoint))
let s3Endpoint = S3Util.computedS3Endpoint(endpoint)

let s3 = S3(accessKeyId: accessKey, secretAccessKey: secretKey, region: region, endpoint: s3Endpoint)

let putObjectRequest = S3.PutObjectRequest(acl: .publicRead, body: bodyData, bucket: bucket, contentLength: Int64(bodyData.count), contentType: mimeType, key: saveKey)
let put = s3.putObject(putObjectRequest)
Expand Down
2 changes: 1 addition & 1 deletion uPic/Models/S3/S3Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class S3Util {
}
return "\(endpoint)/\(bucket)"
} else {
let cEndpoint = "s3.\(region).amazonaws.com"
let cEndpoint = S3Region.endPoint(region)
return "\(schema)\(bucket).\(cEndpoint)"
}
}
Expand Down

0 comments on commit 2af73ae

Please sign in to comment.