/// <summary> /// Handle raw uploaded baked texture data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public void process(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, byte[] data) { m_timeout.Stop(); m_httpListener.RemoveSimpleStreamHandler(m_uploaderPath); m_timeout.Dispose(); if (!httpRequest.RemoteIPEndPoint.Address.Equals(m_remoteAddress)) { httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; return; } // need to check if data is a baked try { UUID newAssetID = UUID.Random(); AssetBase asset = new AssetBase(newAssetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); asset.Data = data; asset.Temporary = true; asset.Local = true; //asset.Flags = AssetFlags.AvatarBake; m_assetCache.Cache(asset); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = UUID.Zero; uploadComplete.state = "complete"; httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDHelpers.SerialiseLLSDReply(uploadComplete)); httpResponse.StatusCode = (int)HttpStatusCode.OK; return; } catch { } httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; }
/// <summary> /// Handle raw uploaded baked texture data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string uploaderCaps(byte[] data, string path, string param) { Action <UUID, byte[]> handlerUpLoad = OnUpLoad; // Don't do this asynchronously, otherwise it's possible for the client to send set appearance information // on another thread which might send out avatar updates before the asset has been put into the asset // service. if (handlerUpLoad != null) { handlerUpLoad(newAssetID, data); } string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = UUID.Zero; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); httpListener.RemoveStreamHandler("POST", uploaderPath); // m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID); return(res); }
/// <summary> /// Handle raw asset upload data via the capability. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string uploaderCaps(byte[] data, string path, string param) { UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); httpListener.RemoveStreamHandler("POST", uploaderPath); // TODO: probably make this a better set of extensions here string extension = ".jp2"; if (m_invType != "image") { extension = ".dat"; } if (m_dumpAssetsToFile) { SaveAssetToFile(m_assetName + extension, data); } handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); } return(res); }
/// <summary> /// Handle raw uploaded asset data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string uploaderCaps(byte[] data, string path, string param) { UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); UUID assetID = UUID.Zero; handlerUpdateItem = OnUpLoad; if (handlerUpdateItem != null) { assetID = handlerUpdateItem(inv, data); } uploadComplete.new_asset = assetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); httpListener.RemoveStreamHandler("POST", uploaderPath); if (m_dumpAssetToFile) { SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); } return(res); }
/// <summary> /// Handle raw uploaded asset data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public void process(IOSHttpRequest request, IOSHttpResponse response, byte[] data) { m_timeout.Stop(); m_httpListener.RemoveSimpleStreamHandler(m_uploaderPath); m_timeout.Dispose(); if (!request.RemoteIPEndPoint.Address.Equals(m_remoteAdress)) { response.StatusCode = (int)HttpStatusCode.Unauthorized; return; } string res = String.Empty; if (OnUpLoad == null) { response.StatusCode = (int)HttpStatusCode.Gone; return; } if (!BunchOfCaps.ValidateAssetData(m_assetType, data)) { response.StatusCode = (int)HttpStatusCode.BadRequest; return; } UUID assetID = OnUpLoad(m_inventoryItemID, m_objectID, data); if (assetID == UUID.Zero) { LLSDAssetUploadError uperror = new LLSDAssetUploadError(); uperror.message = "Failed to update inventory item asset"; uperror.identifier = m_inventoryItemID; res = LLSDHelpers.SerialiseLLSDReply(uperror); } else { LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = assetID.ToString(); uploadComplete.new_inventory_item = m_inventoryItemID; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); } if (m_dumpAssetToFile) { Util.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); } response.StatusCode = (int)HttpStatusCode.OK; response.RawBuffer = Util.UTF8NBGetbytes(res); }
/// <summary> /// Handle raw uploaded baked texture data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string BakedTextureUploaded(byte[] data, string path, string param) { String result; bool decodeFailed = false; UUID newAssetID = UUID.Random(); if (data.Length <= 0) { m_log.ErrorFormat("[CAPS]: Invalid length {0} on UploadBakeRequestPut for {1}", data.Length, path); decodeFailed = true; } else if (m_layerDecoder != null) { decodeFailed = (m_layerDecoder.Decode(newAssetID, data) == false); } if (decodeFailed) { Hashtable badReply = new Hashtable(); badReply["state"] = "error"; badReply["new_asset"] = UUID.Zero; result = LLSDHelpers.SerializeLLSDReply(badReply); } else { AssetBase asset = new AssetBase(newAssetID, "Baked Texture", (sbyte)AssetType.Texture, m_Caps.AgentID.ToString()); asset.Data = data; //Persist baked textures as we will use them in the baked texture cache //asset.Temporary = true; asset.Local = true; m_assetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest()); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = UUID.Zero; uploadComplete.state = "complete"; result = LLSDHelpers.SerializeLLSDReply(uploadComplete); // m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID); } m_Caps.HttpListener.RemoveStreamHandler("POST", m_uploaderPath); return(result); }