Revision d3ea294b src/com/rackspace/cloud/files/api/client/ContainerObjectManager.java
b/src/com/rackspace/cloud/files/api/client/ContainerObjectManager.java | ||
---|---|---|
13 | 13 |
import org.apache.http.client.ClientProtocolException; |
14 | 14 |
import org.apache.http.client.methods.HttpDelete; |
15 | 15 |
import org.apache.http.client.methods.HttpGet; |
16 |
import org.apache.http.client.methods.HttpPut; |
|
16 | 17 |
import org.apache.http.impl.client.BasicResponseHandler; |
17 | 18 |
import org.apache.http.protocol.RequestExpectContinue; |
18 | 19 |
import org.xml.sax.InputSource; |
... | ... | |
128 | 129 |
return resp; |
129 | 130 |
} |
130 | 131 |
|
132 |
public HttpResponse addObject(String Container, String Path, String Object, String type) throws CloudServersException { |
|
133 |
HttpResponse resp = null; |
|
134 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
|
135 |
HttpPut addObject = new HttpPut(Account.getAccount().getStorageUrl() + "/" + Container + "/" + Path + Object); |
|
136 |
|
|
137 |
addObject.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
|
138 |
addObject.addHeader("Content-Type", type); |
|
139 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
140 |
|
|
141 |
try { |
|
142 |
resp = httpclient.execute(addObject); |
|
143 |
} catch (ClientProtocolException e) { |
|
144 |
CloudServersException cse = new CloudServersException(); |
|
145 |
cse.setMessage(e.getLocalizedMessage()); |
|
146 |
throw cse; |
|
147 |
} catch (IOException e) { |
|
148 |
CloudServersException cse = new CloudServersException(); |
|
149 |
cse.setMessage(e.getLocalizedMessage()); |
|
150 |
throw cse; |
|
151 |
} catch (FactoryConfigurationError e) { |
|
152 |
CloudServersException cse = new CloudServersException(); |
|
153 |
cse.setMessage(e.getLocalizedMessage()); |
|
154 |
throw cse; |
|
155 |
} |
|
156 |
return resp; |
|
157 |
} |
|
158 |
|
|
159 |
/* |
|
160 |
* used for adding text files, requires an extra parameter to |
|
161 |
* store the data for the file |
|
162 |
*/ |
|
163 |
public HttpResponse addObject(String Container, String Path, String Object, String type, String data) throws CloudServersException { |
|
164 |
HttpResponse resp = null; |
|
165 |
CustomHttpClient httpclient = new CustomHttpClient(context); |
|
166 |
HttpPut addObject = new HttpPut(Account.getAccount().getStorageUrl() + "/" + Container + "/" + Path + Object); |
|
167 |
|
|
168 |
addObject.addHeader("X-Auth-Token", Account.getAccount().getAuthToken()); |
|
169 |
addObject.addHeader("Content-Type", type); |
|
170 |
httpclient.removeRequestInterceptorByClass(RequestExpectContinue.class); |
|
171 |
|
|
172 |
try { |
|
173 |
resp = httpclient.execute(addObject); |
|
174 |
} catch (ClientProtocolException e) { |
|
175 |
CloudServersException cse = new CloudServersException(); |
|
176 |
cse.setMessage(e.getLocalizedMessage()); |
|
177 |
throw cse; |
|
178 |
} catch (IOException e) { |
|
179 |
CloudServersException cse = new CloudServersException(); |
|
180 |
cse.setMessage(e.getLocalizedMessage()); |
|
181 |
throw cse; |
|
182 |
} catch (FactoryConfigurationError e) { |
|
183 |
CloudServersException cse = new CloudServersException(); |
|
184 |
cse.setMessage(e.getLocalizedMessage()); |
|
185 |
throw cse; |
|
186 |
} |
|
187 |
return resp; |
|
188 |
} |
|
131 | 189 |
|
132 | 190 |
} |
Also available in: Unified diff