public async Task ReDumpling(string owner, int dumplingid, string os) { var identifier = new StateTableIdentifier() { Owner = owner, DumplingId = dumplingid.ToString() }; var entity = await StateTableController.GetEntry(identifier); entity.OriginatingOS = os; await StateTableController.AddOrUpdateStateEntry(entity); await StateTableController.SetState(identifier, "enqueued"); await AnalysisTopicController.EnqueueAnalysisWork(owner, dumplingid.ToString(), os, entity.DumpRelics_uri); }
public async Task <string> PostDumpChunk(string owner, string targetos, int index, ulong filesize, string displayName = "") { if (index > 0 || filesize > int.MaxValue) { throw new NotSupportedException("We do not support chunked files yet, and the file must be <= 2GB or more specifically, int.MaxValue"); } if (!Request.Content.IsMimeMultipartContent("form-data")) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } owner = owner.ToLowerInvariant(); targetos = targetos.ToLowerInvariant(); await DumplingEventHub.FireEvent(new WebAPIStartUploadChunkEvent()); /* Handle Upload */ // Get or create the blob container var container = DumpStorageController.GetContainerForOwner(owner); await container.CreateIfNotExistsAsync(); // Create a AzureBlobStorageMultipartProvider and process the request var path = Path.GetTempPath(); AzureBlobStorageMultipartProvider streamProvider = new AzureBlobStorageMultipartProvider(container, path); await Request.Content.ReadAsMultipartAsync <AzureBlobStorageMultipartProvider>(streamProvider); await DumplingEventHub.FireEvent(new WebAPIFinishedUploadChunkEvent()); /* Meta data handling */ var dump_uri = streamProvider.AzureBlobs.First().Location; if (displayName == string.Empty) { displayName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()); } int dumplingid = await TriageDb.AddDumpAsync(new Dump() { DumpTime = DateTime.Now, DumpPath = dump_uri, DisplayName = displayName, Origin = owner }); StateTableIdentifier id = new StateTableIdentifier() { Owner = owner, DumplingId = dumplingid.ToString(), }; await AnalysisTopicController.EnqueueAnalysisWork(owner, dumplingid.ToString(), targetos, dump_uri); // let the dumpling services know about our dumpling await StateTableController.AddOrUpdateStateEntry(new StateTableEntity(id) { DumpRelics_uri = dump_uri, OriginatingOS = targetos, State = "enqueued" }); // Return result from storing content in the blob container return(dumplingid.ToString()); }