00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_HTTP_UPLOADER
00037 #define INCL_HTTP_UPLOADER
00038
00040 #include "base/globalsdef.h"
00041 #include "base/fscapi.h"
00042 #include "base/constants.h"
00043 #include "http/constants.h"
00044 #include "base/Log.h"
00045 #include "base/util/StringBuffer.h"
00046 #include "inputStream/InputStream.h"
00047 #include "inputStream/StringOutputStream.h"
00048 #include "http/URL.h"
00049 #include "http/HttpConnection.h"
00050
00051 BEGIN_NAMESPACE
00052
00053
00054 #define UPLOAD_URL_RESOURCE "sapi/media"
00055
00067 class HttpUploader {
00068
00069 private:
00070 StringBuffer syncUrl;
00071 StringBuffer sourceURI;
00072 StringBuffer username;
00073 StringBuffer password;
00074 StringBuffer deviceID;
00075 StringBuffer userAgent;
00076 int partialUploadedData;
00077 int totalDataToUpload;
00081 bool useSessionID;
00082 StringBuffer sessionID;
00084 int maxRequestChunkSize;
00086 bool keepalive;
00088 public:
00089
00090 HttpUploader();
00091 virtual ~HttpUploader() { }
00092
00102 virtual int upload(const StringBuffer& luid, InputStream* inputStream);
00103
00104
00105 void setSyncUrl (const StringBuffer& v) { syncUrl = v; }
00106 void setSourceURI (const StringBuffer& v) { sourceURI = v; }
00107 void setUsername (const StringBuffer& v) { username = v; }
00108 void setPassword (const StringBuffer& v) { password = v; }
00109 void setDeviceID (const StringBuffer& v) { deviceID = v; }
00110 void setUserAgent (const StringBuffer& v) { userAgent = v; }
00111 void setUseSessionID (const bool v) { useSessionID = v; }
00112 void setMaxRequestChunkSize(const int v) { maxRequestChunkSize = v; }
00113 void setPartialUploadedData (int v) { partialUploadedData = v; }
00114 void setTotalDataToUpload (int v) { totalDataToUpload = v; }
00119 virtual void setKeepAlive(bool val) { keepalive = val; }
00120
00121 StringBuffer getSessionID() {
00122 return sessionID;
00123 }
00124
00125 protected:
00126
00128 StringBuffer composeURL();
00129
00131 void setRequestHeaders(const StringBuffer& luid, HttpConnection& httpConnection, InputStream& inputStream);
00132
00137 virtual HttpConnection* getHttpConnection() {
00138 return new HttpConnection(userAgent);
00139 }
00140 };
00141
00142 END_NAMESPACE
00143
00145 #endif
00146