public ActionResult GetStream(Context context, string guid)
        {
            var log = new SysLogModel(context: context);

            if (!context.Authenticated)
            {
                return(ApiResults.Unauthorized(context: context));
            }
            var file = BinaryUtilities.Donwload(
                context: context,
                guid: guid.ToUpper());

            if (file == null)
            {
                return(ApiResults.NotFound(context: context));
            }
            var response = CreateFileSteramResult(file);

            log.Finish(
                context: context,
                responseSize: file?.Length ?? 0);
            return(response);
        }
        public ContentResult Upload(Context context, string guid)
        {
            var log = new SysLogModel(context: context);

            if (!context.Authenticated)
            {
                return(ApiResults.Unauthorized(context: context));
            }
            if (context.PostedFiles == null || context.PostedFiles.Count == 0)
            {
                return(ApiResults.BadRequest(context: context));
            }
            var    postedFile = context.PostedFiles[0];
            string filePath   = string.Empty;

            try
            {
                if (!guid.IsNullOrEmpty())
                {
                    guid = guid.ToUpper();
                    var referenceId = FileContentResults.GetReferenceId(
                        context: context,
                        guid: guid);
                    if (referenceId == 0)
                    {
                        return(ApiResults.NotFound(context: context));
                    }
                    var targetGuid = context.QueryStrings.Bool("overwrite")
                        ? guid
                        : Strings.NewGuid();
                    filePath = SaveFileToTemp(
                        guid: targetGuid,
                        file: postedFile);
                    context.ApiRequestBody = CreateAttachmentsHashJson(
                        context: context,
                        guidParam: $"{guid},{targetGuid}",
                        referenceId: referenceId,
                        file: postedFile);
                    var response = new ItemModel(
                        context: context,
                        referenceId: referenceId)
                                   .UpdateByApi(context: context);
                    log.Finish(
                        context: context,
                        responseSize: response?.Content?.Length ?? 0);
                    return(response);
                }
                else
                {
                    if (context.QueryStrings.Long("id") == 0 ||
                        !Mime.ValidateOnApi(contentType: context.ContentType))
                    {
                        return(ApiResults.BadRequest(context: context));
                    }
                    var targetGuid = Strings.NewGuid();
                    filePath = SaveFileToTemp(
                        guid: targetGuid,
                        file: postedFile);
                    var attachment = Attachment(
                        guidParam: targetGuid,
                        referenceId: context.QueryStrings.Long("id"),
                        file: postedFile);
                    var response = attachment.Create(context: context);
                    log.Finish(
                        context: context,
                        responseSize: response?.Content?.Length ?? 0);
                    return(response);
                }
            }
            finally
            {
                Files.DeleteFile(filePath);
            }
        }