Permalink
Browse files

S3 Error Handling. Added CurlClient enumeration

  • Loading branch information...
nrj committed Jun 6, 2010
1 parent 25f7b7a commit 1bc2bd08f722218cfb6db87c7aeed9979082dd6e
View
@@ -6,6 +6,7 @@
//
#import "CurlFTP.h"
+#import "CurlClientType.h"
#import "UploadOperation.h"
#import "Upload.h"
#import "NSString+PathExtras.h"
@@ -53,6 +54,13 @@ - (int)defaultPort
}
+- (int)clientType
+{
+ return CURL_CLIENT_FTP;
+}
+
+
+
/*
* Recursively upload a list of files and directories using the specified host and the users home directory.
*/
@@ -101,13 +109,14 @@ - (Upload *)uploadFilesAndDirectories:(NSArray *)filesAndDirectories toHost:(NSS
[upload setProtocol:[self protocol]];
[upload setProtocolPrefix:[self protocolPrefix]];
+ [upload setClientType:[self clientType]];
[upload setLocalFiles:filesAndDirectories];
[upload setHostname:hostname];
[upload setUsername:username];
[upload setPassword:password];
[upload setPath:[directory stringByRemovingTildePrefix]];
[upload setPort:port];
-
+
[self upload:upload];
return upload;
View
@@ -56,7 +56,7 @@ - (void)dealloc
[super dealloc];
}
-
+
/*
* Generates a new curl_easy_handle.
*
@@ -74,4 +74,11 @@ - (CURL *)newHandle
}
+- (int)clientType
+{
+ // Abstract
+
+ return -1;
+}
+
@end
View
@@ -6,8 +6,10 @@
//
#import "CurlS3.h"
+#import "CurlClientType.h"
#import "S3UploadOperation.h"
#import "Upload.h"
+#import "NSString+PathExtras.h"
@implementation CurlS3
@@ -36,6 +38,12 @@ - (int)defaultPort
}
+- (int)clientType
+{
+ return CURL_CLIENT_S3;
+}
+
+
- (void)upload:(Upload *)record
{
S3UploadOperation *op = [[S3UploadOperation alloc] initWithHandle:[self newHandle] delegate:delegate];
View
@@ -6,6 +6,7 @@
//
#import "CurlSFTP.h"
+#import "CurlClientType.h"
#import "Upload.h"
#import "SSHUploadOperation.h"
#import "NSString+PathExtras.h"
@@ -74,36 +75,9 @@ - (int)defaultPort
}
-- (Upload *)uploadFilesAndDirectories:(NSArray *)filesAndDirectories toHost:(NSString *)hostname username:(NSString *)username
-{
- return [self uploadFilesAndDirectories:filesAndDirectories
- toHost:hostname
- username:username
- password:@""
- directory:@"~/"
- port:[self defaultPort]];
-}
-
-
-- (Upload *)uploadFilesAndDirectories:(NSArray *)filesAndDirectories toHost:(NSString *)hostname username:(NSString *)username password:(NSString *)password
-{
- return [self uploadFilesAndDirectories:filesAndDirectories
- toHost:hostname
- username:username
- password:password
- directory:@""
- port:[self defaultPort]];
-}
-
-
-- (Upload *)uploadFilesAndDirectories:(NSArray *)filesAndDirectories toHost:(NSString *)hostname username:(NSString *)username password:(NSString *)password directory:(NSString *)directory
-{
- return [self uploadFilesAndDirectories:filesAndDirectories
- toHost:hostname
- username:username
- password:password
- directory:directory
- port:[self defaultPort]];
+- (int)clientType
+{
+ return CURL_CLIENT_SFTP;
}
@@ -113,13 +87,15 @@ - (Upload *)uploadFilesAndDirectories:(NSArray *)filesAndDirectories toHost:(NSS
[upload setProtocol:[self protocol]];
[upload setProtocolPrefix:[self protocolPrefix]];
+ [upload setClientType:[self clientType]];
[upload setLocalFiles:filesAndDirectories];
[upload setHostname:hostname];
[upload setUsername:username];
[upload setPassword:password];
[upload setPath:directory];
[upload setPort:port];
-
+ [upload setCanUsePublicKeyAuth:YES];
+
[self upload:upload];
return upload;
View
@@ -12,8 +12,8 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="29"/>
<integer value="449"/>
+ <integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1112,7 +1112,7 @@
<object class="NSSecureTextFieldCell" key="NSCell" id="659381111">
<int key="NSCellFlags">343014976</int>
<int key="NSCellFlags2">4326400</int>
- <string key="NSContents"/>
+ <string key="NSContents">9v9XNUmTHuD1w/0LskIYi2NSSvlAByKKfujIFH9l</string>
<object class="NSFont" key="NSSupport" id="26">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
@@ -1153,7 +1153,7 @@
<object class="NSTextFieldCell" key="NSCell" id="510153074">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">4326400</int>
- <string key="NSContents"/>
+ <string key="NSContents">AKIAILUQ2JJ7YDXEHKRA</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="370322315"/>
<bool key="NSDrawsBackground">YES</bool>
@@ -1300,7 +1300,7 @@
<object class="NSTextFieldCell" key="NSCell" id="18424731">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272761856</int>
- <string key="NSContents">/Users/nrj/Desktop/test-files</string>
+ <string key="NSContents">/Users/nrj/Desktop/avarcas.jpg</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="889008429"/>
<bool key="NSDrawsBackground">YES</bool>
@@ -1317,7 +1317,7 @@
<object class="NSTextFieldCell" key="NSCell" id="5519405">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272761856</int>
- <string key="NSContents">tmp</string>
+ <string key="NSContents">nickjensen</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="637258183"/>
<bool key="NSDrawsBackground">YES</bool>
View
@@ -28,10 +28,10 @@ - (void)awakeFromNib
[sftp setShowProgress:YES];
[sftp setDelegate:self];
- scp = [[CurlSCP alloc] init];
- [scp setVerbose:YES];
- [scp setShowProgress:YES];
- [scp setDelegate:self];
+// scp = [[CurlSCP alloc] init];
+// [scp setVerbose:YES];
+// [scp setShowProgress:YES];
+// [scp setDelegate:self];
s3 = [[CurlS3 alloc] init];
[s3 setVerbose:YES];
View
@@ -0,0 +1,14 @@
+/*
+ * CurlClientType.h
+ * objective-curl
+ *
+ * Copyright 2010 Nick Jensen <http://goto11.net>
+ *
+ */
+
+
+typedef enum {
+ CURL_CLIENT_SFTP,
+ CURL_CLIENT_FTP,
+ CURL_CLIENT_S3
+} CurlClientType;
View
@@ -0,0 +1,72 @@
+//
+// S3ErrorCodes.h
+// objective-curl
+//
+// Copyright 2010 Nick Jensen <http://goto11.net>
+//
+
+const NSString * S3AccessDenied = @"AccessDenied";
+const NSString * S3AccountProblem = @"AccountProblem";
+const NSString * S3AmbiguousGrantByEmailAddress = @"AmbiguousGrantByEmailAddress";
+const NSString * S3BadDigest = @"BadDigest";
+const NSString * S3BucketAlreadyExists = @"BucketAlreadyExists";
+const NSString * S3BucketAlreadyOwnedByYou = @"BucketAlreadyOwnedByYou";
+const NSString * S3BucketNotEmpty = @"BucketNotEmpty";
+const NSString * S3CredentialsNotSupported = @"CredentialsNotSupported";
+const NSString * S3CrossLocationLoggingProhibited = @"CrossLocationLoggingProhibited";
+const NSString * S3EntityTooSmall = @"EntityTooSmall";
+const NSString * S3EntityTooLarge = @"EntityTooLarge";
+const NSString * S3ExpiredToken = @"ExpiredToken";
+const NSString * S3IncompleteBody = @"IncompleteBody";
+const NSString * S3IncorrectNumberOfFilesInPostRequest = @"IncorrectNumberOfFilesInPostRequest";
+const NSString * S3InlineDataTooLarge = @"InlineDataTooLarge";
+const NSString * S3InternalError = @"InternalError";
+const NSString * S3InvalidAccessKeyId = @"InvalidAccessKeyId";
+const NSString * S3InvalidAddressingHeader = @"InvalidAddressingHeader";
+const NSString * S3InvalidArgument = @"InvalidArgument";
+const NSString * S3InvalidBucketName = @"InvalidBucketName";
+const NSString * S3InvalidDigest = @"InvalidDigest";
+const NSString * S3InvalidLocationConstraint = @"InvalidLocationConstraint";
+const NSString * S3InvalidPayer = @"InvalidPayer";
+const NSString * S3InvalidPolicyDocument = @"InvalidPolicyDocument";
+const NSString * S3InvalidRange = @"InvalidRange";
+const NSString * S3InvalidSecurity = @"InvalidSecurity";
+const NSString * S3InvalidSOAPRequest = @"InvalidSOAPRequest";
+const NSString * S3InvalidStorageClass = @"InvalidStorageClass";
+const NSString * S3InvalidTargetBucketForLogging = @"InvalidTargetBucketForLogging";
+const NSString * S3InvalidToken = @"InvalidToken";
+const NSString * S3InvalidURI = @"InvalidURI";
+const NSString * S3KeyTooLong = @"KeyTooLong";
+const NSString * S3MalformedACLError = @"MalformedACLError";
+const NSString * S3MalformedPOSTRequest = @"MalformedPOSTRequest";
+const NSString * S3MalformedXML = @"MalformedXML";
+const NSString * S3MaxMessageLengthExceeded = @"MaxMessageLengthExceeded";
+const NSString * S3MaxPostPreDataLengthExceededError = @"MaxPostPreDataLengthExceededError";
+const NSString * S3MetadataTooLarge = @"MetadataTooLarge";
+const NSString * S3MethodNotAllowed = @"MethodNotAllowed";
+const NSString * S3MissingAttachment = @"MissingAttachment";
+const NSString * S3MissingContentLength = @"MissingContentLength";
+const NSString * S3MissingRequestBodyError = @"MissingRequestBodyError";
+const NSString * S3MissingSecurityElement = @"MissingSecurityElement";
+const NSString * S3MissingSecurityHeader = @"MissingSecurityHeader";
+const NSString * S3NoLoggingStatusForKey = @"NoLoggingStatusForKey";
+const NSString * S3NoSuchBucket = @"NoSuchBucket";
+const NSString * S3NoSuchKey = @"NoSuchKey";
+const NSString * S3NotImplemented = @"NotImplemented";
+const NSString * S3NotSignedUp = @"NotSignedUp";
+const NSString * S3OperationAborted = @"OperationAborted";
+const NSString * S3PermanentRedirect = @"PermanentRedirect";
+const NSString * S3PreconditionFailed = @"PreconditionFailed";
+const NSString * S3Redirect = @"Redirect";
+const NSString * S3RequestIsNotMultiPartContent = @"RequestIsNotMultiPartContent";
+const NSString * S3RequestTimeout = @"RequestTimeout";
+const NSString * S3RequestTimeTooSkewed = @"RequestTimeTooSkewed";
+const NSString * S3RequestTorrentOfBucketError = @"RequestTorrentOfBucketError";
+const NSString * S3SignatureDoesNotMatch = @"SignatureDoesNotMatch";
+const NSString * S3SlowDown = @"SlowDown";
+const NSString * S3TemporaryRedirect = @"TemporaryRedirect";
+const NSString * S3TokenRefreshRequired = @"TokenRefreshRequired";
+const NSString * S3TooManyBuckets = @"TooManyBuckets";
+const NSString * S3UnexpectedContent = @"UnexpectedContent";
+const NSString * S3UnresolvableGrantByEmailAddress = @"UnresolvableGrantByEmailAddress";
+const NSString * S3UserKeyMustBeSpecified = @"UserKeyMustBeSpecified";
View
@@ -5,11 +5,14 @@
*/
-#import "CurlSCP.h"
#import "CurlS3.h"
+#import "CurlSFTP.h"
#import "Upload.h"
#import "FileTransfer.h"
#import "UploadDelegate.h"
#import "RemoteFile.h"
#import "RemoteFolder.h"
#import "TransferStatus.h"
+#import "CurlClientType.h"
+
+
View
@@ -17,11 +17,14 @@
int port;
NSString *path;
NSString *url;
+
+ int clientType;
NSString *username;
NSString *password;
BOOL usePublicKeyAuth;
+ BOOL canUsePublicKeyAuth;
NSString *privateKeyFile;
NSString *publicKeyFile;
@@ -41,10 +44,13 @@
@property(readwrite, copy) NSString *path;
@property(readwrite, copy) NSString *url;
+@property(readwrite, assign) int clientType;
+
@property(readwrite, copy) NSString *username;
@property(readwrite, copy) NSString *password;
@property(readwrite, assign) BOOL usePublicKeyAuth;
+@property(readwrite, assign) BOOL canUsePublicKeyAuth;
@property(readwrite, copy) NSString *privateKeyFile;
@property(readwrite, copy) NSString *publicKeyFile;
View
@@ -17,10 +17,13 @@ @implementation RemoteObject
@synthesize path;
@synthesize url;
+@synthesize clientType;
+
@synthesize username;
@synthesize password;
@synthesize usePublicKeyAuth;
+@synthesize canUsePublicKeyAuth;
@synthesize privateKeyFile;
@synthesize publicKeyFile;
Oops, something went wrong.

0 comments on commit 1bc2bd0

Please sign in to comment.