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;
00077 bool useSessionID;
00078 StringBuffer sessionID;
00080 int maxRequestChunkSize;
00082 bool keepalive;
00084 public:
00085
00086 HttpUploader();
00087 virtual ~HttpUploader() { }
00088
00098 virtual int upload(const StringBuffer& luid, InputStream* inputStream);
00099
00100
00101 void setSyncUrl (const StringBuffer& v) { syncUrl = v; }
00102 void setSourceURI (const StringBuffer& v) { sourceURI = v; }
00103 void setUsername (const StringBuffer& v) { username = v; }
00104 void setPassword (const StringBuffer& v) { password = v; }
00105 void setDeviceID (const StringBuffer& v) { deviceID = v; }
00106 void setUserAgent (const StringBuffer& v) { userAgent = v; }
00107 void setUseSessionID (const bool v) { useSessionID = v; }
00108 void setMaxRequestChunkSize(const int v) { maxRequestChunkSize = v; }
00109
00114 virtual void setKeepAlive(bool val) { keepalive = val; }
00115
00116 StringBuffer getSessionID() {
00117 return sessionID;
00118 }
00119
00120 protected:
00121
00123 StringBuffer composeURL();
00124
00126 void setRequestHeaders(const StringBuffer& luid, HttpConnection& httpConnection, InputStream& inputStream);
00127
00134 StringBuffer parseJSessionId(const StringBuffer& input);
00135
00140 virtual HttpConnection* getHttpConnection() {
00141 return new HttpConnection(userAgent);
00142 }
00143 };
00144
00145 END_NAMESPACE
00146
00148 #endif
00149