Exemplo n.º 1
0
 public string Upload(string fileName)
 {
     var fileinform = new FileInfo(fileName);
     byte[] fileBytes = new byte[fileinform.Length];
     fileinform.OpenRead().Read(fileBytes, 0, (int)fileinform.Length);
     var item = new UploadMethods().UploadSingularFile(fileinform.Name, "file", fileBytes, Constants.UPLOAD_BASEURL + Token + "/" + Folder).GetResponse().GetResponseStream();
     System.Xml.XmlDocument response = new System.Xml.XmlDocument();
     response.Load(item);
     return response.SelectSingleNode("//response//file").Attributes["id"].InnerText;
 }
Exemplo n.º 2
0
 public string[] Upload(string[] fileNames)
 {
     var nameBin = new Dictionary<string, byte[]>();
     foreach (string file in fileNames)
     {
         byte[] fileBuffer;
         fileBuffer = File.ReadAllBytes(file);
         nameBin.Add(file, fileBuffer);
         fileBuffer = null;
     }
     var newMultiUpload = new UploadMethods();
     var uploadReq = newMultiUpload.CreateUploadRequest(new NameValueCollection(), nameBin, Constants.UPLOAD_BASEURL + _token + "/" + _folder);
     List<string> fileIds = new List<string>();
     XmlDocument newXml = new XmlDocument();
     newXml.Load(uploadReq.GetResponse().GetResponseStream());
     foreach (XmlNode node in newXml.SelectNodes("/response/files//file"))
     {
         fileIds.Add(node.Attributes["id"].InnerText);
     }
     return fileIds.ToArray();
 }