SenseNet.ContentRepository.File.Downloaded C# (CSharp) Method

Downloaded() public static method

public static Downloaded ( int fileId ) : void
fileId int
return void
        public static void Downloaded(int fileId)
        {
            DownloadCounter.Increment(fileId);
        }

Same methods

File::Downloaded ( string filePath ) : void

Usage Example

コード例 #1
0
        /// <summary>
        /// Processes the request.
        /// </summary>
        public async Task ProcessRequestCore()
        {
            if (!CheckPermissions())
            {
                _context.Response.StatusCode = 404;
                return;
            }

            var httpHeaderTools = new HttpHeaderTools(_context);
            var endResponse     = HandleResponseForClientCache(httpHeaderTools);

            if (endResponse)
            {
                return;
            }

            //TODO: CheckExecutableType feature is not ported yet from .net framework Services
            // It was designed to handle executable files like aspx or cshtml.
            // See the Repository.ExecutableExtensions property for the full list.

            //TODO: the ImgResizeApplication feature is not ported yet from .net framework Services

            await InitializeRequestedNodeAsync();

            if (RequestedNode == null)
            {
                _context.Response.StatusCode = 404;
                return;
            }

            using (var binaryStream = GetConvertedStream(out var contentType, out var fileName))
            {
                if (binaryStream == null)
                {
                    return;
                }

                _context.Response.ContentType = contentType;
                _context.Response.Headers.Append(HeaderNames.ContentLength, binaryStream.Length.ToString());

                httpHeaderTools.SetContentDispositionHeader(fileName);
                httpHeaderTools.SetCacheControlHeaders(lastModified: RequestedNode.ModificationDate, maxAge: MaxAge);

                _context.Response.StatusCode = 200;

                binaryStream.Position = 0;

                // Let ASP.NET handle sending bytes to the client.
                ResponseLimiter.AssertFileLength(binaryStream.Length);
                await binaryStream.CopyToAsync(_context.Response.Body);
            }

            // Let the client code log file downloads
            if (RequestedNode is File file)
            {
                File.Downloaded(file.Id);
            }
        }
All Usage Examples Of SenseNet.ContentRepository.File::Downloaded