29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Collections.Specialized;
33 using System.Drawing.Imaging;
34 using System.Reflection;
40 using OpenMetaverse.StructuredData;
41 using OpenMetaverse.Imaging;
42 using OpenSim.Framework;
43 using OpenSim.Framework.Capabilities;
44 using OpenSim.Framework.Servers;
45 using OpenSim.Framework.Servers.HttpServer;
46 using OpenSim.Region.Framework.Interfaces;
47 using OpenSim.Services.Interfaces;
50 namespace OpenSim.Capabilities.Handlers
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 private Caps m_HostCapsObj;
59 private bool m_persistBakedTextures;
64 m_assetService = assetService;
65 m_persistBakedTextures = persistBakedTextures;
82 string capsBase =
"/CAPS/" + m_HostCapsObj.CapsObjectPath;
83 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString(
"0000");
86 new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_HostCapsObj.AgentID);
87 uploader.OnUpLoad += BakedTextureUploaded;
89 m_HostCapsObj.HttpListener.AddStreamHandler(
91 "POST", capsBase + uploaderPath, uploader.
uploaderCaps,
"UploadBakedTexture", null));
93 string protocol =
"http://";
95 if (m_HostCapsObj.SSLCaps)
96 protocol =
"https://";
98 string uploaderURL = protocol + m_HostCapsObj.HostName +
":" +
99 m_HostCapsObj.Port.ToString() + capsBase + uploaderPath;
102 uploadResponse.uploader = uploaderURL;
103 uploadResponse.state =
"upload";
105 return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
109 m_log.ErrorFormat(
"[UPLOAD BAKED TEXTURE HANDLER]: {0}{1}", e.Message, e.StackTrace);
120 private void BakedTextureUploaded(UUID assetID, byte[] data)
122 m_log.DebugFormat(
"[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString());
125 asset =
new AssetBase(assetID,
"Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
127 asset.Temporary =
true;
128 asset.Local = !m_persistBakedTextures;
129 m_assetService.Store(asset);
140 private string uploaderPath = String.Empty;
141 private UUID newAssetID;
143 private UUID AgentId = UUID.Zero;
147 newAssetID = UUID.Random();
165 Action<UUID, byte[]> handlerUpLoad = OnUpLoad;
170 if (handlerUpLoad != null)
171 handlerUpLoad(newAssetID, data);
173 string res = String.Empty;
175 uploadComplete.new_asset = newAssetID.ToString();
176 uploadComplete.new_inventory_item = UUID.Zero;
177 uploadComplete.state =
"complete";
179 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
181 httpListener.RemoveStreamHandler(
"POST", uploaderPath);
string uploaderCaps(byte[] data, string path, string param)
Handle raw uploaded baked texture data.
BakedTextureUploader(string path, IHttpServer httpServer, UUID uUID)
string UploadBakedTexture(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
Handle a request from the client for a Uri to upload a baked texture.
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
Asset class. All Assets are reference by this class or a class derived from this class ...
OpenSim.Framework.Capabilities.Caps Caps
Action< UUID, byte[]> OnUpLoad
UploadBakedTextureHandler(Caps caps, IAssetService assetService, bool persistBakedTextures)