Ejemplo n.º 1
0
        private Response AddObject(string bucket, string key, Stream stream)
        {
            if (Request.Url.Query == "?acl")
              {
            return new Response { StatusCode = HttpStatusCode.OK };
              }

              var content = stream.Copy(configuration.MaxBytesPerSecond);

              var s3Object = new S3Object
              {
            Bucket = bucket,
            Key = key,
            ContentType = Request.Headers.ContentType,
            CreationDate = DateTime.UtcNow,
            Content = () => content,
            ContentMD5 = content.GenerateMD5CheckSum(),
            Size = content.Length
              };

              storage.AddObject(s3Object);

              var response = new Response { StatusCode = HttpStatusCode.OK };
              response.WithHeader("ETag", string.Format("\"{0}\"", s3Object.ContentMD5));
              return response;
        }
Ejemplo n.º 2
0
        public void AddObject(S3Object s3Object)
        {
            using (var session = documentStore.OpenSession())
              {
            var content = s3Object.Content();
            content.Position = 0;

            session.Advanced.DatabaseCommands.PutAttachment(s3Object.Id, null, content, new RavenJObject());
            session.Store(s3Object);
            session.SaveChanges();
              }
        }