Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

S3 upload support fairly stable.

  • Loading branch information...
commit 25f7b7a0c86112553ada1381c5ebb94a0e7cf131 1 parent b1eb49b
@nrj authored
View
15 CurlFTP.m
@@ -41,21 +41,6 @@ - (void)dealloc
}
-/*
- * Generates a new curl_easy_handle with FTP-specific options set.
- *
- * See http://curl.haxx.se/libcurl/c/libcurl-easy.html
- */
-- (CURL *)newHandle
-{
- CURL *handle = [super newHandle];
-
- curl_easy_setopt(handle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
-
- return handle;
-}
-
-
- (NSString *)protocolPrefix
{
return @"ftp";
View
1  CurlS3.m
@@ -9,6 +9,7 @@
#import "S3UploadOperation.h"
#import "Upload.h"
+
@implementation CurlS3
View
2  CurlSFTP.h
@@ -7,7 +7,7 @@
#import <Cocoa/Cocoa.h>
#import "CurlFTP.h"
-
+#import "CurlClient.h"
extern int const DEFAULT_SFTP_PORT;
View
2  CurlSFTP.m
@@ -117,7 +117,7 @@ - (Upload *)uploadFilesAndDirectories:(NSArray *)filesAndDirectories toHost:(NSS
[upload setHostname:hostname];
[upload setUsername:username];
[upload setPassword:password];
- [upload setPath:[directory pathForFTP]];
+ [upload setPath:directory];
[upload setPort:port];
[self upload:upload];
View
349 English.lproj/MainMenu.xib
@@ -12,8 +12,8 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="449"/>
<integer value="29"/>
+ <integer value="449"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1092,9 +1092,9 @@
<object class="NSWindowTemplate" id="682341643">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{196, 344}, {438, 166}}</string>
+ <string key="NSWindowRect">{{196, 322}, {486, 188}}</string>
<int key="NSWTFlags">603979776</int>
- <string key="NSWindowTitle">FTP/SFTP Browser</string>
+ <string key="NSWindowTitle">Curl Tester</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
@@ -1106,13 +1106,13 @@
<object class="NSSecureTextField" id="366964228">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{263, 128}, {106, 19}}</string>
+ <string key="NSFrame">{{182, 97}, {284, 19}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSecureTextFieldCell" key="NSCell" id="659381111">
<int key="NSCellFlags">343014976</int>
- <int key="NSCellFlags2">272761856</int>
- <string key="NSContents">JoKQWMzGOYii5hN2rVqEMpSp6k7CBxktYGia18J4</string>
+ <int key="NSCellFlags2">4326400</int>
+ <string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="26">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
@@ -1147,13 +1147,13 @@
<object class="NSTextField" id="370322315">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{14, 127}, {50, 19}}</string>
+ <string key="NSFrame">{{182, 157}, {284, 19}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="510153074">
<int key="NSCellFlags">-1804468671</int>
- <int key="NSCellFlags2">71435264</int>
- <string key="NSContents">AKIAIRK5GRT3UKWJSEJA</string>
+ <int key="NSCellFlags2">4326400</int>
+ <string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="370322315"/>
<bool key="NSDrawsBackground">YES</bool>
@@ -1164,7 +1164,7 @@
<object class="NSTextField" id="638388920">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{88, 127}, {106, 19}}</string>
+ <string key="NSFrame">{{182, 126}, {284, 19}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="790701010">
@@ -1178,18 +1178,18 @@
<reference key="NSTextColor" ref="822441039"/>
</object>
</object>
- <object class="NSTextField" id="845001050">
+ <object class="NSTextField" id="420852267">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{69, 130}, {14, 14}}</string>
+ <string key="NSFrame">{{122, 99}, {57, 14}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="271433282">
+ <object class="NSTextFieldCell" key="NSCell" id="368012523">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272761856</int>
- <string key="NSContents">@</string>
+ <string key="NSContents">Password</string>
<reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="845001050"/>
+ <reference key="NSControlView" ref="420852267"/>
<object class="NSColor" key="NSBackgroundColor" id="907046648">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
@@ -1207,18 +1207,66 @@
</object>
</object>
</object>
- <object class="NSTextField" id="420852267">
+ <object class="NSTextField" id="404061623">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{199, 130}, {59, 14}}</string>
+ <string key="NSFrame">{{11, 20}, {40, 14}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="368012523">
+ <object class="NSTextFieldCell" key="NSCell" id="838208602">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272761856</int>
- <string key="NSContents">password:</string>
+ <string key="NSContents">Source</string>
<reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="420852267"/>
+ <reference key="NSControlView" ref="404061623"/>
+ <reference key="NSBackgroundColor" ref="907046648"/>
+ <reference key="NSTextColor" ref="1002444076"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="826476616">
+ <reference key="NSNextResponder" ref="686122530"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{335, 20}, {97, 14}}</string>
+ <reference key="NSSuperview" ref="686122530"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="277508104">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents">Remote Directory</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="826476616"/>
+ <reference key="NSBackgroundColor" ref="907046648"/>
+ <reference key="NSTextColor" ref="1002444076"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="279816955">
+ <reference key="NSNextResponder" ref="686122530"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{118, 159}, {61, 14}}</string>
+ <reference key="NSSuperview" ref="686122530"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="146667799">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents">Username</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="279816955"/>
+ <reference key="NSBackgroundColor" ref="907046648"/>
+ <reference key="NSTextColor" ref="1002444076"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="36474131">
+ <reference key="NSNextResponder" ref="686122530"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{118, 129}, {61, 14}}</string>
+ <reference key="NSSuperview" ref="686122530"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="392895861">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents">Hostname</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="36474131"/>
<reference key="NSBackgroundColor" ref="907046648"/>
<reference key="NSTextColor" ref="1002444076"/>
</object>
@@ -1226,13 +1274,13 @@
<object class="NSButton" id="348785713">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">289</int>
- <string key="NSFrame">{{338, 15}, {96, 28}}</string>
+ <string key="NSFrame">{{239, 38}, {96, 28}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="706508283">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134348800</int>
- <string key="NSContents">Upload File</string>
+ <string key="NSContents">Upload to</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="348785713"/>
<int key="NSButtonFlags">-2038284033</int>
@@ -1246,13 +1294,13 @@
<object class="NSTextField" id="889008429">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{14, 20}, {227, 19}}</string>
+ <string key="NSFrame">{{14, 42}, {222, 19}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="18424731">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272761856</int>
- <string key="NSContents">/Users/nrj/Desktop/test-empty-folder</string>
+ <string key="NSContents">/Users/nrj/Desktop/test-files</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="889008429"/>
<bool key="NSDrawsBackground">YES</bool>
@@ -1260,11 +1308,28 @@
<reference key="NSTextColor" ref="822441039"/>
</object>
</object>
+ <object class="NSTextField" id="637258183">
+ <reference key="NSNextResponder" ref="686122530"/>
+ <int key="NSvFlags">290</int>
+ <string key="NSFrame">{{338, 43}, {128, 19}}</string>
+ <reference key="NSSuperview" ref="686122530"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="5519405">
+ <int key="NSCellFlags">-1804468671</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents">tmp</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="637258183"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <reference key="NSBackgroundColor" ref="548390568"/>
+ <reference key="NSTextColor" ref="822441039"/>
+ </object>
+ </object>
<object class="NSProgressIndicator" id="916500852">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">1314</int>
<object class="NSPSMatrix" key="NSDrawMatrix"/>
- <string key="NSFrame">{{13, 51}, {417, 12}}</string>
+ <string key="NSFrame">{{13, 73}, {454, 12}}</string>
<reference key="NSSuperview" ref="686122530"/>
<int key="NSpiFlags">16648</int>
<double key="NSMaxValue">100</double>
@@ -1272,11 +1337,11 @@
<object class="NSMatrix" id="801609171">
<reference key="NSNextResponder" ref="686122530"/>
<int key="NSvFlags">289</int>
- <string key="NSFrame">{{14, 86}, {336, 18}}</string>
+ <string key="NSFrame">{{20, 97}, {93, 78}}</string>
<reference key="NSSuperview" ref="686122530"/>
<bool key="NSEnabled">YES</bool>
- <int key="NSNumRows">1</int>
- <int key="NSNumCols">4</int>
+ <int key="NSNumRows">4</int>
+ <int key="NSNumCols">1</int>
<object class="NSMutableArray" key="NSCells">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSButtonCell" id="322784260">
@@ -1311,7 +1376,7 @@
<object class="NSButtonCell" id="287243917">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">131072</int>
- <string key="NSContents">SCP</string>
+ <string key="NSContents">SCP (broken)</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="801609171"/>
<int key="NSButtonFlags">1211912703</int>
@@ -1320,7 +1385,7 @@
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
- <object class="NSButtonCell" id="503629970">
+ <object class="NSButtonCell" id="380031538">
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">131072</int>
<string key="NSContents">Amazon S3</string>
@@ -1333,7 +1398,7 @@
<int key="NSPeriodicInterval">75</int>
</object>
</object>
- <string key="NSCellSize">{81, 18}</string>
+ <string key="NSCellSize">{93, 18}</string>
<string key="NSIntercellSpacing">{4, 2}</string>
<int key="NSMatrixFlags">1151868928</int>
<string key="NSCellClass">NSActionCell</string>
@@ -1392,8 +1457,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
- <int key="NSSelectedCol">3</int>
- <reference key="NSSelectedCell" ref="503629970"/>
+ <int key="NSSelectedRow">3</int>
+ <reference key="NSSelectedCell" ref="380031538"/>
<reference key="NSBackgroundColor" ref="907046648"/>
<reference key="NSCellBackgroundColor" ref="850842249"/>
<object class="NSFont" key="NSFont">
@@ -1403,7 +1468,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
</object>
- <string key="NSFrameSize">{438, 166}</string>
+ <string key="NSFrameSize">{486, 188}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
@@ -1412,23 +1477,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSUserDefaultsController" id="1022775234">
<bool key="NSSharedInstance">YES</bool>
</object>
- <object class="NSWindowTemplate" id="416097360">
- <int key="NSWindowStyleMask">15</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{196, 357}, {475, 153}}</string>
- <int key="NSWTFlags">603979776</int>
- <string key="NSWindowTitle">Window</string>
- <string key="NSWindowClass">NSWindow</string>
- <nil key="NSViewClass"/>
- <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
- <object class="NSView" key="NSWindowView" id="2910854">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{475, 153}</string>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
- <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
- </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -1995,22 +2043,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
- <string key="label">sheet</string>
- <reference key="source" ref="962184478"/>
- <reference key="destination" ref="416097360"/>
- </object>
- <int key="connectionID">619</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="416097360"/>
- <reference key="destination" ref="1050"/>
- </object>
- <int key="connectionID">621</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
<string key="label">fileField</string>
<reference key="source" ref="962184478"/>
<reference key="destination" ref="889008429"/>
@@ -2057,6 +2089,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">651</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">remoteDirField</string>
+ <reference key="source" ref="962184478"/>
+ <reference key="destination" ref="637258183"/>
+ </object>
+ <int key="connectionID">730</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2957,15 +2997,19 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="object" ref="686122530"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="370322315"/>
- <reference ref="638388920"/>
- <reference ref="845001050"/>
- <reference ref="420852267"/>
- <reference ref="366964228"/>
<reference ref="889008429"/>
- <reference ref="348785713"/>
<reference ref="916500852"/>
<reference ref="801609171"/>
+ <reference ref="370322315"/>
+ <reference ref="279816955"/>
+ <reference ref="366964228"/>
+ <reference ref="420852267"/>
+ <reference ref="638388920"/>
+ <reference ref="36474131"/>
+ <reference ref="637258183"/>
+ <reference ref="404061623"/>
+ <reference ref="348785713"/>
+ <reference ref="826476616"/>
</object>
<reference key="parent" ref="682341643"/>
</object>
@@ -3017,20 +3061,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="parent" ref="638388920"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">488</int>
- <reference key="object" ref="845001050"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="271433282"/>
- </object>
- <reference key="parent" ref="686122530"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">489</int>
- <reference key="object" ref="271433282"/>
- <reference key="parent" ref="845001050"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">599</int>
<reference key="object" ref="420852267"/>
<object class="NSMutableArray" key="children">
@@ -3045,21 +3075,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="parent" ref="420852267"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">617</int>
- <reference key="object" ref="416097360"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="2910854"/>
- </object>
- <reference key="parent" ref="0"/>
- <string key="objectName">Sheet</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">618</int>
- <reference key="object" ref="2910854"/>
- <reference key="parent" ref="416097360"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">624</int>
<reference key="object" ref="348785713"/>
<object class="NSMutableArray" key="children">
@@ -3099,9 +3114,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="322784260"/>
<reference ref="417159644"/>
- <reference ref="735198592"/>
+ <reference ref="380031538"/>
<reference ref="287243917"/>
- <reference ref="503629970"/>
+ <reference ref="735198592"/>
</object>
<reference key="parent" ref="686122530"/>
</object>
@@ -3116,20 +3131,90 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="parent" ref="801609171"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">655</int>
- <reference key="object" ref="735198592"/>
+ <int key="objectID">713</int>
+ <reference key="object" ref="380031538"/>
<reference key="parent" ref="801609171"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">658</int>
+ <int key="objectID">716</int>
<reference key="object" ref="287243917"/>
<reference key="parent" ref="801609171"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">662</int>
- <reference key="object" ref="503629970"/>
+ <int key="objectID">717</int>
+ <reference key="object" ref="735198592"/>
<reference key="parent" ref="801609171"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">720</int>
+ <reference key="object" ref="279816955"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="146667799"/>
+ </object>
+ <reference key="parent" ref="686122530"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">721</int>
+ <reference key="object" ref="146667799"/>
+ <reference key="parent" ref="279816955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">722</int>
+ <reference key="object" ref="36474131"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="392895861"/>
+ </object>
+ <reference key="parent" ref="686122530"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">723</int>
+ <reference key="object" ref="392895861"/>
+ <reference key="parent" ref="36474131"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">724</int>
+ <reference key="object" ref="637258183"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="5519405"/>
+ </object>
+ <reference key="parent" ref="686122530"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">725</int>
+ <reference key="object" ref="5519405"/>
+ <reference key="parent" ref="637258183"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">726</int>
+ <reference key="object" ref="404061623"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="838208602"/>
+ </object>
+ <reference key="parent" ref="686122530"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">727</int>
+ <reference key="object" ref="838208602"/>
+ <reference key="parent" ref="404061623"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">728</int>
+ <reference key="object" ref="826476616"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="277508104"/>
+ </object>
+ <reference key="parent" ref="686122530"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">729</int>
+ <reference key="object" ref="277508104"/>
+ <reference key="parent" ref="826476616"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -3332,8 +3417,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>474.IBPluginDependency</string>
<string>486.IBPluginDependency</string>
<string>487.IBPluginDependency</string>
- <string>488.IBPluginDependency</string>
- <string>489.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>5.ImportedFromIB2</string>
<string>56.IBPluginDependency</string>
@@ -3346,11 +3429,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>58.ImportedFromIB2</string>
<string>599.IBPluginDependency</string>
<string>600.IBPluginDependency</string>
- <string>617.IBEditorWindowLastContentRect</string>
- <string>617.IBPluginDependency</string>
- <string>617.IBWindowTemplateEditedContentRect</string>
- <string>617.NSWindowTemplate.visibleAtLaunch</string>
- <string>618.IBPluginDependency</string>
<string>624.IBPluginDependency</string>
<string>625.IBPluginDependency</string>
<string>626.IBPluginDependency</string>
@@ -3359,11 +3437,21 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>647.IBPluginDependency</string>
<string>648.IBPluginDependency</string>
<string>650.IBPluginDependency</string>
- <string>655.IBPluginDependency</string>
- <string>658.IBPluginDependency</string>
- <string>662.IBPluginDependency</string>
+ <string>713.IBPluginDependency</string>
+ <string>716.IBPluginDependency</string>
+ <string>717.IBPluginDependency</string>
<string>72.IBPluginDependency</string>
<string>72.ImportedFromIB2</string>
+ <string>720.IBPluginDependency</string>
+ <string>721.IBPluginDependency</string>
+ <string>722.IBPluginDependency</string>
+ <string>723.IBPluginDependency</string>
+ <string>724.IBPluginDependency</string>
+ <string>725.IBPluginDependency</string>
+ <string>726.IBPluginDependency</string>
+ <string>727.IBPluginDependency</string>
+ <string>728.IBPluginDependency</string>
+ <string>729.IBPluginDependency</string>
<string>73.IBPluginDependency</string>
<string>73.ImportedFromIB2</string>
<string>74.IBPluginDependency</string>
@@ -3575,9 +3663,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{377, 517}, {438, 166}}</string>
+ <string>{{380, 458}, {486, 188}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{377, 517}, {438, 166}}</string>
+ <string>{{380, 458}, {486, 188}}</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -3588,8 +3676,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@@ -3601,10 +3687,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{335, 413}, {475, 153}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{335, 413}, {475, 153}}</string>
- <boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -3616,9 +3699,17 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -3661,7 +3752,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">705</int>
+ <int key="maxID">730</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3689,6 +3780,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>hostnameField</string>
<string>passwordField</string>
<string>progressBar</string>
+ <string>remoteDirField</string>
<string>sheet</string>
<string>typeSelector</string>
<string>usernameField</string>
@@ -3701,6 +3793,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>NSTextField</string>
<string>NSTextField</string>
<string>NSProgressIndicator</string>
+ <string>NSTextField</string>
<string>NSWindow</string>
<string>NSMatrix</string>
<string>NSTextField</string>
View
2  TestController.h
@@ -6,6 +6,7 @@
//
#import <Cocoa/Cocoa.h>
+#import <objective-curl/objective-curl.h>
@class Upload, CurlFTP, CurlSFTP, CurlSCP, CurlS3;
@@ -23,6 +24,7 @@
IBOutlet NSTextField *hostnameField;
IBOutlet NSTextField *usernameField;
IBOutlet NSTextField *passwordField;
+ IBOutlet NSTextField *remoteDirField;
IBOutlet NSButton *connectButton;
IBOutlet NSTextField *fileField;
IBOutlet NSProgressIndicator *progressBar;
View
28 TestController.m
@@ -6,7 +6,7 @@
//
#import "TestController.h"
-#import <objective-curl/objective-curl.h>
+
@implementation TestController
@@ -15,8 +15,8 @@ @implementation TestController
- (void)awakeFromNib
-{
- NSLog([CurlObject libcurlVersion]);
+{
+ NSLog(@"Version: %@", [CurlObject libcurlVersion]);
ftp = [[CurlFTP alloc] init];
[ftp setVerbose:NO];
@@ -24,12 +24,12 @@ - (void)awakeFromNib
[ftp setDelegate:self];
sftp = [[CurlSFTP alloc] init];
- [sftp setVerbose:NO];
+ [sftp setVerbose:YES];
[sftp setShowProgress:YES];
[sftp setDelegate:self];
scp = [[CurlSCP alloc] init];
- [scp setVerbose:NO];
+ [scp setVerbose:YES];
[scp setShowProgress:YES];
[scp setDelegate:self];
@@ -46,7 +46,7 @@ - (IBAction)uploadFile:(id)sender
id <CurlClient>client = nil;
- switch([typeSelector selectedColumn])
+ switch([typeSelector selectedRow])
{
default:
case 0:
@@ -67,7 +67,7 @@ - (IBAction)uploadFile:(id)sender
toHost:[hostnameField stringValue]
username:[usernameField stringValue]
password:[passwordField stringValue]
- directory:@"nickjensen"];
+ directory:[remoteDirField stringValue]];
// [newUpload setUsePublicKeyAuth:YES];
// [newUpload setPrivateKeyFile:[@"~/.ssh/id_rsa" stringByExpandingTildeInPath]];
@@ -96,14 +96,14 @@ - (void)uploadDidBegin:(Upload *)record
- (void)uploadDidProgress:(Upload *)record toPercent:(NSNumber *)percent;
{
- NSLog(@".");
+// NSLog(@".");
// NSLog(@"Uploading %d of %d Files", [upload totalFilesUploaded], [upload totalFiles]);
- NSLog(@" Current File: %.0f of %.0f Bytes Uploaded (%d%%)",
- [[record currentTransfer] totalBytesUploaded], [[record currentTransfer] totalBytes], [[record currentTransfer] percentComplete]);
-
- NSLog(@"Total Progress: %.0f of %.0f Bytes Uploaded (%d%%)",
- [record totalBytesUploaded], [record totalBytes], [record progress]);
- NSLog(@"");
+// NSLog(@" Current File: %.0f of %.0f Bytes Uploaded (%d%%)",
+// [[record currentTransfer] totalBytesUploaded], [[record currentTransfer] totalBytes], [[record currentTransfer] percentComplete]);
+//
+// NSLog(@"Total Progress: %.0f of %.0f Bytes Uploaded (%d%%)",
+// [record totalBytesUploaded], [record totalBytes], [record progress]);
+// NSLog(@"");
}
View
38 extras/NSFileManager+MimeType.m
@@ -10,24 +10,38 @@
@implementation NSFileManager (MimeType)
-
+ (NSString *)mimeTypeForFileAtPath:(NSString *)path
{
- NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];
- NSURLResponse *resp = nil;
- NSError *err = nil;
-
- [NSURLConnection sendSynchronousRequest:req
- returningResponse:&resp
- error:&err];
+ BOOL isDir = NO;
+ NSFileManager *mgr = [[NSFileManager alloc] init];
+ NSString *mimeType = @"";
- if (err)
+ if ([mgr fileExistsAtPath:path isDirectory:&isDir] && isDir)
+ {
+ mimeType = @"application/x-directory";
+ }
+ else
{
- NSLog(@"Error trying to get MimeType of file: %@ - %@", path, [err description]);
- return @"";
+ NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];
+ NSURLResponse *resp = nil;
+ NSError *err = nil;
+
+ [NSURLConnection sendSynchronousRequest:req
+ returningResponse:&resp
+ error:&err];
+ if (!err)
+ {
+ mimeType = [resp MIMEType];
+ }
+ else
+ {
+ NSLog(@"Error trying to get MimeType of file: %@ - %@", path, [err description]);
+ }
}
- return [resp MIMEType];
+ [mgr release];
+
+ return mimeType;
}
@end
View
3  extras/NSString+PathExtras.h
@@ -10,8 +10,7 @@
@interface NSString (PathExtras)
-- (NSString *)pathForFTP;
-- (NSString *)appendPathForFTP:(NSString *)path;
+- (NSString *)stringByAddingTildePrefix;
- (NSString *)stringByRemovingTildePrefix;
@end
View
15 extras/NSString+PathExtras.m
@@ -10,7 +10,8 @@
@implementation NSString (PathExtras)
-- (NSString *)pathForFTP
+
+- (NSString *)stringByAddingTildePrefix
{
if ([self isEqualToString:@""])
return @"~/";
@@ -23,20 +24,9 @@ - (NSString *)pathForFTP
else
path = [NSMutableString stringWithString:self];
- // SFTP requires a trailing slash.
- if(![[path substringFromIndex:([path length] - 1)] isEqualToString:@"/"])
- [path appendString:@"/"];
-
return path;
}
-- (NSString *)appendPathForFTP:(NSString *)path;
-{
- if ([path isEqualToString:@"."])
- return self;
-
- return [[self stringByAppendingPathComponent:path] pathForFTP];
-}
- (NSString *)stringByRemovingTildePrefix
{
@@ -48,4 +38,5 @@ - (NSString *)stringByRemovingTildePrefix
return self;
}
+
@end
View
1  include/objective-curl.h
@@ -6,6 +6,7 @@
#import "CurlSCP.h"
+#import "CurlS3.h"
#import "Upload.h"
#import "FileTransfer.h"
#import "UploadDelegate.h"
View
19 model/FileTransfer.h
@@ -8,13 +8,16 @@
#import <Cocoa/Cocoa.h>
#import <stdio.h>
#import <sys/stat.h>
-
+#import <curl/curl.h>
@interface FileTransfer : NSObject
{
NSString *localPath;
NSString *remotePath;
+ struct curl_slist *headers;
+ struct curl_slist *postQuote;
+
BOOL isEmptyDirectory;
BOOL fileNotFound;
@@ -41,10 +44,24 @@
- (id)initWithLocalPath:(NSString *)aLocalPath remotePath:(NSString *)aRemotePath;
+- (struct curl_slist *)headers;
+
+- (void)appendHeader:(const char *)header;
+
+- (void)cleanupHeaders;
+
+- (struct curl_slist *)postQuote;
+
+- (void)appendPostQuote:(const char *)quote;
+
+- (void)cleanupPostQuotes;
+
- (FILE *)getHandle;
- (int)getInfo:(struct stat *)info;
- (NSString *)getEmptyFilePath;
++ (NSString *)emptyFilename;
+
@end
View
68 model/FileTransfer.m
@@ -33,6 +33,9 @@ - (id)initWithLocalPath:(NSString *)aLocalPath remotePath:(NSString *)aRemotePat
[self setLocalPath:aLocalPath];
[self setRemotePath:aRemotePath];
+ headers = NULL;
+ postQuote = NULL;
+
percentComplete = 0;
totalBytes = 0;
totalBytesUploaded = 0;
@@ -41,11 +44,64 @@ - (id)initWithLocalPath:(NSString *)aLocalPath remotePath:(NSString *)aRemotePat
return self;
}
+
+- (void)dealloc
+{
+ [localPath release]; localPath = nil;
+ [remotePath release]; remotePath = nil;
+ if (headers) {
+ curl_slist_free_all(headers); headers = nil;
+ }
+ if (postQuote) {
+ curl_slist_free_all(postQuote); postQuote = nil;
+ }
+ [super dealloc];
+}
+
+
- (NSString *)getEmptyFilePath
{
- NSString *str = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Contents/Frameworks/objective-curl.framework/Resources/.empty"];
+ NSArray *pathComponents = [NSArray arrayWithObjects:[[NSBundle bundleForClass:[self class]] bundlePath], @"Resources", [FileTransfer emptyFilename], NULL];
- return str;
+ return [NSString pathWithComponents:pathComponents];
+}
+
+- (struct curl_slist *)headers
+{
+ return headers;
+}
+
+- (void)appendHeader:(const char *)header
+{
+ headers = curl_slist_append(headers, header);
+}
+
+- (void)cleanupHeaders
+{
+ if (headers)
+ {
+ curl_slist_free_all(headers);
+ headers = NULL;
+ }
+}
+
+- (struct curl_slist *)postQuote
+{
+ return postQuote;
+}
+
+- (void)appendPostQuote:(const char *)quote
+{
+ postQuote = curl_slist_append(postQuote, quote);
+}
+
+- (void)cleanupPostQuotes
+{
+ if (postQuote)
+ {
+ curl_slist_free_all(postQuote);
+ postQuote = NULL;
+ }
}
- (FILE *)getHandle
@@ -64,6 +120,7 @@ - (FILE *)getHandle
return fh;
}
+
- (int)getInfo:(struct stat *)info
{
if([self isEmptyDirectory])
@@ -76,9 +133,16 @@ - (int)getInfo:(struct stat *)info
}
}
+
- (NSString *)description
{
return [NSString stringWithFormat:@"<FileTransfer localPath='%@' remotePath='%@' isEmptyDirectory='%d'", localPath, remotePath, isEmptyDirectory];
}
+
++ (NSString *)emptyFilename
+{
+ return @".empty";
+}
+
@end
View
149 objective-curl.xcodeproj/nrj.mode1v3
@@ -266,11 +266,9 @@
<string>0867D691FE84028FC02AAC07</string>
<string>0B76051210DF12CB00BE0666</string>
<string>08FB77AEFE84172EC02AAC07</string>
- <string>0BEDAAB910EC44E200ED2C69</string>
+ <string>0B40BA0411AF477E00158EEB</string>
<string>0BD3CFB5110CF2F700478C99</string>
<string>0B76052210DF134E00BE0666</string>
- <string>089C1665FE841158C02AAC07</string>
- <string>0B2E387A10DF2C3300E82CB2</string>
<string>034768DFFF38A50411DB9C8B</string>
<string>1C37FBAC04509CD000000102</string>
<string>1C37FAAC04509CD000000102</string>
@@ -278,14 +276,13 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
- <integer>20</integer>
- <integer>16</integer>
- <integer>5</integer>
+ <integer>4</integer>
+ <integer>2</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
- <string>{{0, 251}, {274, 658}}</string>
+ <string>{{0, 14}, {274, 760}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@@ -297,14 +294,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {291, 676}}</string>
+ <string>{{0, 0}, {291, 778}}</string>
<key>GroupTreeTableConfiguration</key>
<array>
<string>MainColumn</string>
<real>274</real>
</array>
<key>RubberWindowFrame</key>
- <string>43 146 1225 717 0 0 1440 878 </string>
+ <string>8 344 1440 819 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
@@ -322,7 +319,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20306471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
- <string>S3UploadOperation.m</string>
+ <string>TestController.m</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@@ -330,11 +327,11 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20406471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
- <string>S3UploadOperation.m</string>
+ <string>TestController.m</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
- <string>0B0A231411A9D26A00D73D5D</string>
+ <string>0BC986B911B1D04B00F326C8</string>
<key>history</key>
<array>
<string>0BE3002010E6CC46004EB7BE</string>
@@ -370,48 +367,50 @@
<string>0BBCE80C1131D91C001676F3</string>
<string>0BB3F007114472EF008CC281</string>
<string>0B9DB88E114F12B7000A8688</string>
- <string>0BE030FD1158FEE200221405</string>
<string>0BE030FE1158FEE200221405</string>
<string>0B29404D1164DFE2006303AC</string>
- <string>0B9CD9C61180EEF40009A182</string>
- <string>0B02FD1A119A348A00639D42</string>
<string>0BB4D89411A21AE100B62DF4</string>
- <string>0BB4D98911A22C6100B62DF4</string>
- <string>0BB4D98A11A22C6100B62DF4</string>
<string>0BB4D98B11A22C6100B62DF4</string>
- <string>0B80546111A9041200CEA13A</string>
<string>0B80546511A9041200CEA13A</string>
<string>0B80546611A9041200CEA13A</string>
- <string>0B80546C11A9041200CEA13A</string>
<string>0B8054A711A9091900CEA13A</string>
<string>0B8054B411A90A7500CEA13A</string>
<string>0BE0A35811A90FD200FBFB1F</string>
<string>0BE0A35911A90FD200FBFB1F</string>
- <string>0BE0A35C11A90FD200FBFB1F</string>
- <string>0BE0A35D11A90FD200FBFB1F</string>
- <string>0BE0A35E11A90FD200FBFB1F</string>
- <string>0BE0A37611A910E900FBFB1F</string>
<string>0BE0A39711A911F400FBFB1F</string>
- <string>0B096B0811A915C40098EA71</string>
- <string>0B096B2011A916310098EA71</string>
- <string>0B096B6811A9195D0098EA71</string>
- <string>0BEA163F11A91AB500CD0031</string>
<string>0B0A20BF11A9929A00D73D5D</string>
- <string>0B0A211811A9A2C900D73D5D</string>
<string>0B0A211A11A9A2C900D73D5D</string>
<string>0B0A211B11A9A2C900D73D5D</string>
- <string>0B0A211C11A9A2C900D73D5D</string>
- <string>0B0A213211A9A3EE00D73D5D</string>
- <string>0B0A216911A9B4F500D73D5D</string>
<string>0B0A21A711A9BB4200D73D5D</string>
- <string>0B0A223C11A9C62E00D73D5D</string>
<string>0B0A228811A9CB8F00D73D5D</string>
- <string>0B0A228911A9CB8F00D73D5D</string>
- <string>0B0A22BD11A9CD0600D73D5D</string>
- <string>0B0A22C611A9CDBF00D73D5D</string>
- <string>0B0A230D11A9D25D00D73D5D</string>
- <string>0B0A231211A9D26A00D73D5D</string>
- <string>0B0A231311A9D26A00D73D5D</string>
+ <string>0B0A231C11AB486A00D73D5D</string>
+ <string>0B0A234911AB4A4700D73D5D</string>
+ <string>0B0A242511AB714400D73D5D</string>
+ <string>0B0A246411ACAB9600D73D5D</string>
+ <string>0B0A247411ACAE4400D73D5D</string>
+ <string>0B0A24D811ACB28C00D73D5D</string>
+ <string>0B0A24D911ACB28C00D73D5D</string>
+ <string>0B0A24E111ACB37700D73D5D</string>
+ <string>0B0A24E311ACB37700D73D5D</string>
+ <string>0B0A24E411ACB37700D73D5D</string>
+ <string>0B0A24E511ACB37700D73D5D</string>
+ <string>0B0A254011ACBA3000D73D5D</string>
+ <string>0B0A254111ACBA3000D73D5D</string>
+ <string>0B0A256211ACD69500D73D5D</string>
+ <string>0B0A256311ACD69500D73D5D</string>
+ <string>0B0A256411ACD69500D73D5D</string>
+ <string>0B40BA1111AF495F00158EEB</string>
+ <string>0B40BA1211AF495F00158EEB</string>
+ <string>0B40BA5411AF4D4200158EEB</string>
+ <string>0B40BA6011AF4DA000158EEB</string>
+ <string>0B40BA6611AF4ED900158EEB</string>
+ <string>0B40BA7E11AF50F300158EEB</string>
+ <string>0B40BA7F11AF50F300158EEB</string>
+ <string>0B40BA8C11AF525A00158EEB</string>
+ <string>0BC986B511B1D04B00F326C8</string>
+ <string>0BC986B611B1D04B00F326C8</string>
+ <string>0BC986B711B1D04B00F326C8</string>
+ <string>0BC986B811B1D04B00F326C8</string>
</array>
</dict>
<key>SplitCount</key>
@@ -423,14 +422,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 0}, {929, 671}}</string>
+ <string>{{0, 0}, {1144, 773}}</string>
<key>RubberWindowFrame</key>
- <string>43 146 1225 717 0 0 1440 878 </string>
+ <string>8 344 1440 819 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
- <string>671pt</string>
+ <string>773pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@@ -443,9 +442,9 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{0, 676}, {929, 0}}</string>
+ <string>{{0, 778}, {1144, 0}}</string>
<key>RubberWindowFrame</key>
- <string>43 146 1225 717 0 0 1440 878 </string>
+ <string>8 344 1440 819 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@@ -454,7 +453,7 @@
</dict>
</array>
<key>Proportion</key>
- <string>929pt</string>
+ <string>1144pt</string>
</dict>
</array>
<key>Name</key>
@@ -469,9 +468,9 @@
</array>
<key>TableOfContents</key>
<array>
- <string>0B0A20C511A9929A00D73D5D</string>
+ <string>0BC986BA11B1D04B00F326C8</string>
<string>1CE0B1FE06471DED0097A5F4</string>
- <string>0B0A20C611A9929A00D73D5D</string>
+ <string>0BC986BB11B1D04B00F326C8</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@@ -607,17 +606,17 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
- <string>0B0A231111A9D25D00D73D5D</string>
+ <string>0BC986BD11B1D04B00F326C8</string>
+ <string>0BC986BE11B1D04B00F326C8</string>
+ <string>0BC986BF11B1D04B00F326C8</string>
<string>1C530D57069F1CE1000CFCEE</string>
- <string>0B0A20D811A9942600D73D5D</string>
- <string>0B0A20D911A9942600D73D5D</string>
<string>1CD10A99069EF8BA00B06720</string>
<string>0B25C54110DF0E3F0040E9C1</string>
- <string>1C78EAAD065D492600B07095</string>
<string>/Users/nrj/Code/Cocoa/objective-curl/objective-curl.xcodeproj</string>
+ <string>1C78EAAD065D492600B07095</string>
</array>
<key>WindowString</key>
- <string>43 146 1225 717 0 0 1440 878 </string>
+ <string>8 344 1440 819 0 0 1920 1178 </string>
<key>WindowToolsV3</key>
<array>
<dict>
@@ -640,7 +639,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CD0528F0623707200166675</string>
<key>PBXProjectModuleLabel</key>
- <string>UploadOperation.h</string>
+ <string>S3ErrorParser.m</string>
<key>StatusBarVisibility</key>
<true/>
</dict>
@@ -649,7 +648,7 @@
<key>Frame</key>
<string>{{0, 0}, {1139, 543}}</string>
<key>RubberWindowFrame</key>
- <string>203 74 1139 765 0 0 1440 878 </string>
+ <string>311 200 1139 765 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
@@ -673,7 +672,7 @@
<key>Frame</key>
<string>{{0, 548}, {1139, 176}}</string>
<key>RubberWindowFrame</key>
- <string>203 74 1139 765 0 0 1440 878 </string>
+ <string>311 200 1139 765 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXBuildResultsModule</string>
@@ -696,18 +695,18 @@
<key>TableOfContents</key>
<array>
<string>0B25C54110DF0E3F0040E9C1</string>
- <string>0B0A20B811A9926C00D73D5D</string>
+ <string>0BC986A511B1D03500F326C8</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.buildV3</string>
<key>WindowString</key>
- <string>203 74 1139 765 0 0 1440 878 </string>
+ <string>311 200 1139 765 0 0 1920 1178 </string>
<key>WindowToolGUID</key>
<string>0B25C54110DF0E3F0040E9C1</string>
<key>WindowToolIsVisible</key>
- <false/>
+ <true/>
</dict>
<dict>
<key>FirstTimeWindowDisplayed</key>
@@ -790,10 +789,10 @@
<key>Frame</key>
<string>{{473, 0}, {569, 301}}</string>
<key>RubberWindowFrame</key>
- <string>46 272 1042 606 0 0 1440 878 </string>
+ <string>101 572 1042 606 0 0 1920 1178 </string>
</dict>
<key>RubberWindowFrame</key>
- <string>46 272 1042 606 0 0 1440 878 </string>
+ <string>101 572 1042 606 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXDebugSessionModule</string>
@@ -816,18 +815,18 @@
<key>TableOfContents</key>
<array>
<string>1CD10A99069EF8BA00B06720</string>
- <string>0B0A20D011A9942600D73D5D</string>
+ <string>0BC986A611B1D03500F326C8</string>
<string>1C162984064C10D400B95A72</string>
- <string>0B0A20D111A9942600D73D5D</string>
- <string>0B0A20D211A9942600D73D5D</string>
- <string>0B0A20D311A9942600D73D5D</string>
- <string>0B0A20D411A9942600D73D5D</string>
- <string>0B0A20D511A9942600D73D5D</string>
+ <string>0BC986A711B1D03500F326C8</string>
+ <string>0BC986A811B1D03500F326C8</string>
+ <string>0BC986A911B1D03500F326C8</string>
+ <string>0BC986AA11B1D03500F326C8</string>
+ <string>0BC986AB11B1D03500F326C8</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debugV3</string>
<key>WindowString</key>
- <string>46 272 1042 606 0 0 1440 878 </string>
+ <string>101 572 1042 606 0 0 1920 1178 </string>
<key>WindowToolGUID</key>
<string>1CD10A99069EF8BA00B06720</string>
<key>WindowToolIsVisible</key>
@@ -863,7 +862,7 @@
<key>Frame</key>
<string>{{0, 0}, {0, 0}}</string>
<key>RubberWindowFrame</key>
- <string>115 54 1151 790 0 0 1440 878 </string>
+ <string>306 238 1151 790 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
@@ -889,7 +888,7 @@
<key>Frame</key>
<string>{{0, 5}, {1151, 0}}</string>
<key>RubberWindowFrame</key>
- <string>115 54 1151 790 0 0 1440 878 </string>
+ <string>306 238 1151 790 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXProjectFindModule</string>
@@ -912,13 +911,13 @@
<key>TableOfContents</key>
<array>
<string>1C530D57069F1CE1000CFCEE</string>
- <string>0B0A21A311A9BB4000D73D5D</string>
- <string>0B0A21A411A9BB4000D73D5D</string>
+ <string>0BC986AD11B1D03500F326C8</string>
+ <string>0BC986AE11B1D03500F326C8</string>
<string>1CDD528C0622207200134675</string>
<string>1CD0528E0623707200166675</string>
</array>
<key>WindowString</key>
- <string>115 54 1151 790 0 0 1440 878 </string>
+ <string>306 238 1151 790 0 0 1920 1178 </string>
<key>WindowToolGUID</key>
<string>1C530D57069F1CE1000CFCEE</string>
<key>WindowToolIsVisible</key>
@@ -955,7 +954,7 @@
<key>Frame</key>
<string>{{0, 0}, {1181, 518}}</string>
<key>RubberWindowFrame</key>
- <string>226 84 1181 559 0 0 1440 878 </string>
+ <string>305 135 1181 559 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXDebugCLIModule</string>
@@ -978,13 +977,13 @@
<key>TableOfContents</key>
<array>
<string>1C78EAAD065D492600B07095</string>
- <string>0B0A20D611A9942600D73D5D</string>
+ <string>0BC986BC11B1D04B00F326C8</string>
<string>1C78EAAC065D492600B07095</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.consoleV3</string>
<key>WindowString</key>
- <string>226 84 1181 559 0 0 1440 878 </string>
+ <string>305 135 1181 559 0 0 1920 1178 </string>
<key>WindowToolGUID</key>
<string>1C78EAAD065D492600B07095</string>
<key>WindowToolIsVisible</key>
@@ -1449,7 +1448,7 @@
<key>TableOfContents</key>
<array>
<string>1C0AD2AF069F1E9B00FABCE6</string>
- <string>0B5FEBA711150926005A5F84</string>
+ <string>0B0A241D11AB703800D73D5D</string>
<string>1CA6456E063B45B4001379D8</string>
</array>
<key>ToolbarConfiguration</key>
View
3,284 objective-curl.xcodeproj/nrj.pbxuser
558 additions, 2,726 deletions not shown
View
16 objective-curl.xcodeproj/project.pbxproj
@@ -14,6 +14,8 @@
0B0B975D10F58CED007DBFA8 /* NSString+PathExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B0B975910F58CED007DBFA8 /* NSString+PathExtras.m */; };
0B1CC2B51117332600AC5959 /* TestController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B76053510DF13DB00BE0666 /* TestController.m */; };
0B2E387B10DF2C3300E82CB2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0B2E387A10DF2C3300E82CB2 /* MainMenu.xib */; };
+ 0B40BA0711AF479E00158EEB /* S3ErrorParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B40BA0511AF479E00158EEB /* S3ErrorParser.h */; };
+ 0B40BA0811AF479E00158EEB /* S3ErrorParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B40BA0611AF479E00158EEB /* S3ErrorParser.m */; };
0B5FEE6E11165123005A5F84 /* CurlClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B5FEE6D11165123005A5F84 /* CurlClient.h */; settings = {ATTRIBUTES = (Public, ); }; };
0B5FF03A11166DE8005A5F84 /* objective-curl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B5FF03911166DE8005A5F84 /* objective-curl.h */; settings = {ATTRIBUTES = (Public, ); }; };
0B725E5510F2CC4D001C614D /* RemoteObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B725E5310F2CC4D001C614D /* RemoteObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -115,6 +117,8 @@
0B0B975710F58CED007DBFA8 /* NSString+MD5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MD5.m"; sourceTree = "<group>"; };
0B0B975810F58CED007DBFA8 /* NSString+PathExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+PathExtras.h"; sourceTree = "<group>"; };
0B0B975910F58CED007DBFA8 /* NSString+PathExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+PathExtras.m"; sourceTree = "<group>"; };
+ 0B40BA0511AF479E00158EEB /* S3ErrorParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = S3ErrorParser.h; sourceTree = "<group>"; };
+ 0B40BA0611AF479E00158EEB /* S3ErrorParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = S3ErrorParser.m; sourceTree = "<group>"; };
0B5FEE6D11165123005A5F84 /* CurlClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurlClient.h; sourceTree = "<group>"; };
0B5FF03911166DE8005A5F84 /* objective-curl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "objective-curl.h"; sourceTree = "<group>"; };
0B725E5310F2CC4D001C614D /* RemoteObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteObject.h; sourceTree = "<group>"; };
@@ -246,6 +250,7 @@
08FB77AEFE84172EC02AAC07 /* Framework Classes */ = {
isa = PBXGroup;
children = (
+ 0B40BA0411AF477E00158EEB /* util */,
0BEDAAB910EC44E200ED2C69 /* extras */,
0BD6240610DF1BF4004D8C5B /* include */,
0BD3CFB5110CF2F700478C99 /* operations */,
@@ -266,6 +271,15 @@
name = "Framework Classes";
sourceTree = "<group>";
};
+ 0B40BA0411AF477E00158EEB /* util */ = {
+ isa = PBXGroup;
+ children = (
+ 0B40BA0511AF479E00158EEB /* S3ErrorParser.h */,
+ 0B40BA0611AF479E00158EEB /* S3ErrorParser.m */,
+ );
+ path = util;
+ sourceTree = "<group>";
+ };
0B76051210DF12CB00BE0666 /* Test */ = {
isa = PBXGroup;
children = (
@@ -430,6 +444,7 @@
0B80545911A9035600CEA13A /* S3UploadOperation.h in Headers */,
0B8054A111A9070600CEA13A /* NSFileManager+MimeType.h in Headers */,
0BE0A34111A90E3400FBFB1F /* NSString+S3.h in Headers */,
+ 0B40BA0711AF479E00158EEB /* S3ErrorParser.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -568,6 +583,7 @@
0B80545A11A9035600CEA13A /* S3UploadOperation.m in Sources */,
0B8054A211A9070600CEA13A /* NSFileManager+MimeType.m in Sources */,
0BE0A34211A90E3400FBFB1F /* NSString+S3.m in Sources */,
+ 0B40BA0811AF479E00158EEB /* S3ErrorParser.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
12 operations/CurlOperation.h
@@ -1,8 +1,10 @@
-/*!
- @header CurlOperation.h
- @abstract Abstract class used for as the base for all transfer operations.
- @discussion Abstract class used for as the base for all transfer operations.
-*/
+//
+// CurlOperation.h
+// objective-curl
+//
+// Copyright 2010 Nick Jensen <http://goto11.net>
+//
+
#import <Cocoa/Cocoa.h>
#include <sys/stat.h>
View
3  operations/CurlOperation.m
@@ -2,11 +2,10 @@
// CurlOperation.m
// objective-curl
//
-// Base class for all curl related operations.
-//
// Copyright 2010 Nick Jensen <http://goto11.net>
//
+
#import "CurlOperation.h"
#import "RemoteObject.h"
View
13 operations/S3UploadOperation.h
@@ -8,8 +8,19 @@
#import <Cocoa/Cocoa.h>
#import "UploadOperation.h"
-@interface S3UploadOperation : UploadOperation {
+@interface S3UploadOperation : UploadOperation {
+
+ int httpStatus;
+ NSString *errorMessage;
+
}
+@property(readwrite, assign) int httpStatus;
+@property(readwrite, copy) NSString *errorMessage;
+
+static size_t headerFunction(void *ptr, size_t size, size_t nmemb, void *data);
+static size_t writeFunction(void *ptr, size_t size, size_t nmemb, void *data);
+
+
@end
View
119 operations/S3UploadOperation.m
@@ -7,27 +7,74 @@
#import "S3UploadOperation.h"
#import "Upload.h"
+#import "UploadDelegate.h"
#import "FileTransfer.h"
+#import "S3ErrorParser.h"
#import "NSString+S3.h"
#import "NSString+PathExtras.h"
#import "NSFileManager+MimeType.h"
+#import "NSObject+Extensions.h"
+
@implementation S3UploadOperation
-- (NSString *)urlForTransfer:(FileTransfer *)file
+@synthesize httpStatus;
+
+@synthesize errorMessage;
+
+
+/*
+ * Parse and set the HTTP status from Amazon
+ */
+static size_t headerFunction(void *ptr, size_t size, size_t nmemb, void *data)
{
- NSString *path = [[upload hostname] stringByAppendingPathComponent:[file remotePath]];
+ int len = size * nmemb;
+ S3UploadOperation *op = (S3UploadOperation *)data;
- if ([file isEmptyDirectory])
- path = [path stringByAppendingPathComponent:@".empty"];
+ // TODO - parse and set httpStatus
- NSString *url = [NSString stringWithFormat:@"%@://%@", [upload protocolPrefix], path];
+ printf("\n%s\n", (char *)ptr);
- return url;
+ return len;
+}
+
+
+/*
+ * If we got a response body from PUT request and the httpStatus != 2XX then we handle it as an error
+ * and bail out.
+ */
+static size_t writeFunction(void *ptr, size_t size, size_t nmemb, void *data)
+{
+ int len = size * nmemb;
+ S3UploadOperation *op = (S3UploadOperation *)data;
+
+ // TODO - if httpStatus != 2XX then parse the error code.
+ BOOL isError = [op httpStatus] < 200 || [op httpStatus] > 299;
+
+ [op setErrorMessage:[S3ErrorParser parseErrorMessage:[NSString stringWithCString:(char *)ptr]]];
+
+ return isError ? 0 : len;
+}
+
+
+/*
+ * Set curl options for Amazon S3.
+ */
+- (void)setProtocolSpecificOptions
+{
+ curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, headerFunction);
+ curl_easy_setopt(handle, CURLOPT_HEADERDATA, self);
+ curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writeFunction);
+ curl_easy_setopt(handle, CURLOPT_WRITEDATA, self);
}
+/*
+ * Set S3 Auth/HTTP Headers for the current file being uploaded.
+ *
+ */
- (void)setFileSpecificOptions:(FileTransfer *)file
{
// These act the same as username and password
@@ -39,17 +86,16 @@ - (void)setFileSpecificOptions:(FileTransfer *)file
[dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss zzzz"];
NSString *date = [dateFormatter stringFromDate:[NSDate date]];
- NSString *resource = [NSString stringWithFormat:@"/%@", [file remotePath]];
-
- if ([file isEmptyDirectory])
- resource = [resource stringByAppendingPathComponent:@".empty"];
-
+ NSString *resource = [NSString stringWithFormat:@"/%@", [[file remotePath] stringByRemovingTildePrefix]];
+
// Get the content type of the file we're uploading
-// NSString *contentType = [NSFileManager mimeTypeForFileAtPath:[file localPath]];
- NSString *contentType = @"binary/octet-stream";
+ NSString *contentType = [NSFileManager mimeTypeForFileAtPath:[file localPath]];
+ // TODO - don't hardcode this
+ NSString *acl = @"x-amz-acl:public-read";
+
// Details of the request to be signed
- NSString *stringToSign = [NSString stringWithFormat:@"PUT\n\n%@\n%@\n%@", contentType, date, resource];
+ NSString *stringToSign = [NSString stringWithFormat:@"PUT\n\n%@\n%@\n%@\n%@", contentType, date, acl, resource];
// Construct the S3 authorization header
NSString *authString = [NSString stringWithFormat:@"AWS %@:%@",
@@ -61,16 +107,57 @@ - (void)setFileSpecificOptions:(FileTransfer *)file
headers = curl_slist_append(headers, "User-Agent:");
headers = curl_slist_append(headers, "Accept:");
headers = curl_slist_append(headers, "Expect:");
+ headers = curl_slist_append(headers, [acl UTF8String]);
headers = curl_slist_append(headers, [[NSString stringWithFormat:@"Content-Type: %@", contentType] UTF8String]);
headers = curl_slist_append(headers, [[NSString stringWithFormat:@"Date: %@", date] UTF8String]);
headers = curl_slist_append(headers, [[NSString stringWithFormat:@"Authorization: %@", authString] UTF8String]);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
- curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0);
+
+ // TODO - figure out a way to free the headers
}
-- (void)setAuthOptions{ }
+
+/*
+ * Overridden to handle Amazon S3 Specific Failures.
+ *
+ */
+- (void)handleUploadFailed:(CURLcode)result
+{
+ // The upload operation failed.
+ int status;
+ switch (result)
+ {
+ // Aborted from the write_func? Amazon S3 threw an error...
+ case CURLE_WRITE_ERROR:
+ status = TRANSFER_STATUS_FAILED;
+ break;
+
+ // Otherwise, process as a normal error.
+ default:
+ return [super handleUploadFailed:result];
+ }
+
+ [upload setStatus:status];
+
+ if (delegate && [delegate respondsToSelector:@selector(uploadDidFail:message:)])
+ {
+ [[delegate invokeOnMainThread] uploadDidFail:upload message:errorMessage];
+ }
+}
+
+
+- (NSString *)urlForTransfer:(FileTransfer *)file
+{
+ NSString *filePath = [[file remotePath] stringByRemovingTildePrefix];
+
+ NSString *path = [[NSString stringWithFormat:@"%@:%d", [upload hostname], [upload port]] stringByAppendingPathComponent:filePath];
+
+ NSString *url = [NSString stringWithFormat:@"%@://%@", [upload protocolPrefix], path];
+
+ return url;
+}
@end
View
58 operations/SSHUploadOperation.m
@@ -7,7 +7,9 @@
#import "SSHUploadOperation.h"
#import "Upload.h"
+#import "FileTransfer.h"
#import "NSString+MD5.h"
+#import "NSString+PathExtras.h"
#import "NSObject+Extensions.h"
@@ -51,25 +53,12 @@ static int hostKeyCallback(CURL *curl, const struct curl_khkey *knownKey, const
}
-/*
- * Thread entry point for recursive SFTP uploads.
- */
-- (void)main
+- (void)setProtocolSpecificOptions
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [super setProtocolSpecificOptions];
curl_easy_setopt(handle, CURLOPT_SSH_KEYFUNCTION, hostKeyCallback);
curl_easy_setopt(handle, CURLOPT_SSH_KEYDATA, self);
-
- [super main];
-
- [pool release];
-}
-
-
-- (void)setAuthOptions
-{
- [super setAuthOptions];
if ([upload usePublicKeyAuth])
{
@@ -80,6 +69,33 @@ - (void)setAuthOptions
}
+- (void)setFileSpecificOptions:(FileTransfer *)file
+{
+ if ([file isEmptyDirectory])
+ {
+ const char *removeTempFile = [[NSString stringWithFormat:@"RM \"%@\"", [[file remotePath] stringByRemovingTildePrefix]] UTF8String];
+
+ printf("\nQuote Command is %s\n", removeTempFile);
+
+ [file appendPostQuote:removeTempFile];
+ }
+
+ curl_easy_setopt(handle, CURLOPT_POSTQUOTE, [file postQuote]);
+}
+
+
+- (NSString *)urlForTransfer:(FileTransfer *)file
+{
+ NSString *filePath = [[file remotePath] stringByRemovingTildePrefix];
+
+ NSString *path = [[NSString stringWithFormat:@"%@:%d", [upload hostname], [upload port]] stringByAppendingPathComponent:filePath];
+
+ NSString *url = [NSString stringWithFormat:@"%@://%@", [upload protocolPrefix], path];
+
+ return url;
+}
+
+
/*
* How should we handle the unknown host key fingerprint. If a delegate implementation exists then query
* the delegate for an answer. Otherwise proceed.
@@ -127,18 +143,6 @@ - (int)acceptMismatchedHostFingerprint:(NSString *)fingerprint forUpload:(Upload
/*
- * Returns a char pointer containing the delete temp file command. Be sure to call free() on the result.
- *
- */
-- (char *)removeTempFileCommand:(NSString *)tmpFilePath
-{
- char *command = malloc(strlen("RM \"\"") + [tmpFilePath length] + 1);
- sprintf(command, "RM \"%s\"", [tmpFilePath UTF8String]);
- return command;
-}
-
-
-/*
* Log warning for unknown hostKey.
*/
- (void)showUnknownKeyWarningForHost:(NSString *)hostname
View
11 operations/UploadOperation.h
@@ -10,10 +10,9 @@
#import "CurlClient.h"
-extern NSString * const TMP_FILENAME;
-
@class Upload, FileTransfer;
+
@interface UploadOperation : CurlOperation
{
Upload *upload;
@@ -23,12 +22,12 @@ extern NSString * const TMP_FILENAME;
static int handleUploadProgress(UploadOperation *operation, int connected, double dltotal, double dlnow, double ultotal, double ulnow);
-- (void)setAuthOptions;
-
-- (NSString *)urlForTransfer:(FileTransfer *)file;
+- (void)setProtocolSpecificOptions;
- (void)setFileSpecificOptions:(FileTransfer *)file;
+- (NSString *)urlForTransfer:(FileTransfer *)file;
+
- (NSArray *)enumerateFilesToUpload:(NSArray *)files prefix:(NSString *)prefix totalBytes:(double *)totalBytes;
- (void)handleUploadResult:(CURLcode)result;
@@ -37,8 +36,6 @@ static int handleUploadProgress(UploadOperation *operation, int connected, doubl
- (void)performUploadDelegateSelector:(SEL)aSelector withArgument:(id)arg;
-- (char *)removeTempFileCommand:(NSString *)basePath;
-
- (NSString *)credentials;
- (void)startByteTimer;
View
81 operations/UploadOperation.m
@@ -14,9 +14,6 @@
#import "NSString+PathExtras.h"
-NSString * const TMP_FILENAME = @".empty";
-
-
@implementation UploadOperation
@@ -30,13 +27,13 @@ - (void)main
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- // Set curl options
+ // Set options for uploading
curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, self);
curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, handleUploadProgress);
// Set interface specific auth options
- [self setAuthOptions];
+ [self setProtocolSpecificOptions];
double totalBytes = 0;
@@ -82,26 +79,16 @@ - (void)main
curl_easy_setopt(handle, CURLOPT_READDATA, fh);
curl_easy_setopt(handle, CURLOPT_URL, [url UTF8String]);
- // If we are trying to upload an empty directory we upload an empty file inside of it
- // and create a quote command to clean it up after.
-
- struct curl_slist *postRun = NULL;
- char *removeTempFile = NULL;
-
-// if ([file isEmptyDirectory])
-// {
-// postRun = curl_slist_append(postRun, [self removeTempFileCommand:[relativePath stringByRemovingTildePrefix]]);
-// }
-
- // Add quote commands, if any.
-// curl_easy_setopt(handle, CURLOPT_POSTQUOTE, postRun);
-
// Perform
result = curl_easy_perform(handle);
- // Cleanup.
- curl_slist_free_all(postRun);
- free(removeTempFile);
+ // Cleanup any headers
+ [file cleanupHeaders];
+
+ // Cleanup any quote commands
+ [file cleanupPostQuotes];
+
+ // Close the file handle
fclose(fh);
// If this upload wasn't successful, bail out.
@@ -112,7 +99,7 @@ - (void)main
[upload setTotalFilesUploaded:i + 1];
}
- // Cleanup.
+ // Cleanup the files array.
[filesToUpload release];
// Process the result of the upload.
@@ -125,25 +112,33 @@ - (void)main
- (NSString *)urlForTransfer:(FileTransfer *)file
{
- NSString *relativePath = [file isEmptyDirectory] ?
- [[file remotePath] stringByAppendingPathComponent:TMP_FILENAME] : [file remotePath];
+ NSString *filePath = [[file remotePath] stringByAddingTildePrefix];
+
+ NSString *path = [[NSString stringWithFormat:@"%@:%d", [upload hostname], [upload port]] stringByAppendingPathComponent:filePath];
- NSString *url = [NSString stringWithFormat:@"%@://%@:%d/%@",
- [upload protocolPrefix], [upload hostname], [upload port], relativePath];
+ NSString *url = [NSString stringWithFormat:@"%@://%@", [upload protocolPrefix], path];