aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs
index 70957f5..b4eb7db 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs
@@ -168,6 +168,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
168 DoGet(rdata); 168 DoGet(rdata);
169 break; 169 break;
170 case "put" : 170 case "put" :
171 DoPut(rdata);
172 break;
171 case "post" : 173 case "post" :
172 case "delete" : 174 case "delete" :
173 default : 175 default :
@@ -240,6 +242,48 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
240 242
241 } 243 }
242 244
245 private void DoPut(AssetRequestData rdata)
246 {
247 Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method);
248
249 // The only parameter we accept is an LLUUID for
250 // the asset
251
252 if (rdata.parameters.Length == 1)
253 {
254 rdata.initXmlReader();
255 XmlReader xml = rdata.reader;
256
257 if (!xml.ReadToFollowing("Asset"))
258 {
259 Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path);
260 rdata.Fail(Rest.HttpStatusCodeBadRequest,
261 Rest.HttpStatusDescBadRequest);
262 }
263
264 AssetBase asset = new AssetBase();
265 asset.ID = rdata.parameters[0];
266 asset.Name = xml.GetAttribute("name");
267 asset.Description = xml.GetAttribute("desc");
268 asset.Type = SByte.Parse(xml.GetAttribute("type"));
269 asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0;
270 asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0;
271 asset.Data = (new System.Text.ASCIIEncoding()).GetBytes(Rest.Base64ToString(xml.ReadElementContentAsString("Asset", "")));
272
273 Rest.AssetServices.AddAsset(asset);
274 }
275 else
276 {
277 Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path);
278 rdata.Fail(Rest.HttpStatusCodeNotFound,
279 Rest.HttpStatusDescNotFound);
280 }
281
282 rdata.Complete();
283 rdata.Respond("Asset " + rdata.method + ": Normal completion");
284
285 }
286
243 internal class AssetRequestData : RequestData 287 internal class AssetRequestData : RequestData
244 { 288 {
245 internal AssetRequestData(OSHttpRequest request, OSHttpResponse response, string prefix) 289 internal AssetRequestData(OSHttpRequest request, OSHttpResponse response, string prefix)