public override byte[] GetFile(Mythic.Structs.UploadFileRegistrationMessage fileReg, int chunk_size)
        {
            string      response;
            UploadReply reply;

            byte[]      data;
            List <byte> fileChunks = new List <byte>();
            int         i          = 1;

            // Set requisite attributes
            fileReg.action     = "upload";
            fileReg.chunk_size = chunk_size;
            //fileReg.chunk_num = i;
            if (fileReg.full_path != "" && fileReg.full_path != null && (fileReg.task_id == "" || fileReg.task_id == null))
            {
                throw new Exception("Full path given but no task_id set. Aborting.");
            }
            try
            {
                do
                {
                    fileReg.chunk_num = i;
                    if (Send(fileReg.task_id, JsonConvert.SerializeObject(fileReg)))
                    {
                        response = (string)Inbox.GetMessage(fileReg.task_id);
                        reply    = JsonConvert.DeserializeObject <UploadReply>(response);
                        data     = System.Convert.FromBase64String(reply.chunk_data);
                        for (int j = 0; j < data.Length; j++)
                        {
                            fileChunks.Add(data[j]);
                        }
                        i++;
                    }
                    else
                    {
                        break;
                    }
                } while (i <= reply.total_chunks);
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(fileChunks.ToArray());
        }
Exemple #2
0
 public abstract byte[] GetFile(Mythic.Structs.UploadFileRegistrationMessage fileReg, int chunk_size);
 public override byte[] GetFile(Mythic.Structs.UploadFileRegistrationMessage fileReg, int chunk_size)
 {
     throw new NotImplementedException();
 }