Beispiel #1
0
        public async Task <HttpResponseMessage> Put(string name, bool preserveTimestamps = false)
        {
            var metadata = GetFilteredMetadataFromHeaders(ReadInnerHeaders);
            var etag     = GetEtag();

            var options = new FileActions.PutOperationOptions();

            long contentSize;

            if (long.TryParse(GetHeader(Constants.FileSystem.RavenFsSize), out contentSize))
            {
                options.ContentSize = contentSize;
            }

            DateTimeOffset lastModified;

            if (DateTimeOffset.TryParse(GetHeader(Constants.RavenLastModified), out lastModified))
            {
                options.LastModified = lastModified;
            }

            options.PreserveTimestamps      = preserveTimestamps;
            options.ContentLength           = Request.Content.Headers.ContentLength;
            options.TransferEncodingChunked = Request.Headers.TransferEncodingChunked ?? false;

            await FileSystem.Files.PutAsync(name, etag, metadata, () => Request.Content.ReadAsStreamAsync(), options);

            Synchronizations.StartSynchronizeDestinationsInBackground();

            return(GetEmptyMessage(HttpStatusCode.Created));
        }
Beispiel #2
0
        public HttpResponseMessage Post(string name)
        {
            name = FileHeader.Canonize(name);

            var metadata = GetFilteredMetadataFromHeaders(ReadInnerHeaders);
            var etag     = GetEtag();

            Storage.Batch(accessor =>
            {
                Synchronizations.AssertFileIsNotBeingSynced(name);

                Historian.Update(name, metadata);
                Files.UpdateMetadata(name, metadata, etag);

                Synchronizations.StartSynchronizeDestinationsInBackground();
            });

            //Hack needed by jquery on the client side. We need to find a better solution for this
            return(GetEmptyMessage(HttpStatusCode.NoContent));
        }