public static S3Container Create(string serviceId, string serviceSecret, string name) { S3Service service = new S3Service(serviceId, serviceSecret); GetResponse(service.CreateRequest(PutMethod, name)); return(new S3Container(service, name, DateTime.MinValue)); }
public static IEnumerable <S3Container> ListContainers(string serviceId, string serviceSecret) { S3Service service = new S3Service(serviceId, serviceSecret); XElement response = GetResponse(service.CreateRequest(GetMethod)); return(response.Descendants( S3 + "Bucket").Select(b => new S3Container(service, b.Element(S3 + "Name").Value, XmlConvert.ToDateTime(b.Element(S3 + "CreationDate").Value, XmlDateTimeSerializationMode.Utc)))); }
public static IEnumerable<S3Container> ListContainers(string serviceId, string serviceSecret) { S3Service service = new S3Service(serviceId, serviceSecret); XElement response = GetResponse(service.CreateRequest(GetMethod)); return response.Descendants( S3 + "Bucket").Select(b => new S3Container(service, b.Element(S3 + "Name").Value, XmlConvert.ToDateTime(b.Element(S3 + "CreationDate").Value, XmlDateTimeSerializationMode.Utc))); }
public void Read(Action <Stream> action) { try { GetResponse(_service.CreateRequest(GetMethod, _containerName, string.Empty, _name), action); } catch (WebException e) { if (e.Response != null) { HttpWebResponse response = (HttpWebResponse)e.Response; if (response.StatusCode != HttpStatusCode.NotFound) { throw; } } else { throw; } } }
public IEnumerable <IBlock> ListBlocks(string prefix, int pageSize) { bool isTruncated = false; string markerName = null; do { StringBuilder queryBuilder = new StringBuilder("?max-keys="); queryBuilder.Append(pageSize); if (!string.IsNullOrEmpty(prefix)) { queryBuilder.AppendFormat("&prefix={0}", prefix); } if (!string.IsNullOrEmpty(markerName)) { queryBuilder.AppendFormat("&marker={0}", markerName); } XElement response = GetResponse(_service.CreateRequest(GetMethod, _name, queryBuilder.ToString(), string.Empty)); isTruncated = XmlConvert.ToBoolean(response.Element(S3 + "IsTruncated").Value); foreach (IBlock block in response.Elements(S3 + "Contents").Select(o => (IBlock) new S3Block( _service, _name, o.Element(S3 + "Key").Value, XmlConvert.ToDateTime(o.Element(S3 + "LastModified").Value, XmlDateTimeSerializationMode.Utc), XmlConvert.ToInt64(o.Element(S3 + "Size").Value)))) { yield return(block); markerName = block.Name; } }while (isTruncated); }
public static S3Container Create(string serviceId, string serviceSecret, string name) { S3Service service = new S3Service(serviceId, serviceSecret); GetResponse(service.CreateRequest(PutMethod, name)); return new S3Container(service, name, DateTime.MinValue); }