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

            if (name.Length > SystemParameters.KeyMost)
            {
                Log.Debug("File '{0}' was not created due to illegal name length", name);
                return GetMessageWithString(string.Format("File '{0}' was not created due to illegal name length", name), HttpStatusCode.BadRequest);
            }

            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).ConfigureAwait(false);

            SynchronizationTask.Context.NotifyAboutWork();

            return GetEmptyMessage(HttpStatusCode.Created);
        }
Example #2
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);
		}