Code Monkey home page Code Monkey logo

file-service's Issues

DeleteFileByFileTokenAsync ServerApi未实现

你好!

return await Task.FromResult(new Result(ResultErrorCodes.Failure, "暂未实现"));

这个是不是下次升级才会有的?
目前只能用UserFileController中的删除对吗?

调用删除接口的时候出现了The transaction associated with this command is not the connection's active transaction

我的mysql和aspcore程序都是是创建在ubuntu上的,调用删除的http接口的时候aspcore的控制台爆出了下面这个exception:
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: The transaction associated with this command is not the connection's active transaction; see mysql-net/MySqlConnector#474
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlCommand.cs:line 233
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlCommand.cs:line 60
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in C:\projects\dapper\Dapper\SqlMapper.cs:line 552
at Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable1 commandTimeout, Nullable1 commandType) in C:\projects\dapper\Dapper\SqlMapper.cs:line 443
at Mondol.FileService.Db.Repositories.Impls.FileRepository.<>c__DisplayClass11_0.b__0() in C:\Users\IssaccLee\Documents\GitHub\file-service\src\Mondol.FileService.Db\Repositories\Impls\FileRepository.cs:line 133
at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown --- at Mondol.FileService.Controllers.UserFileController.DeleteAsync(String fileToken, String ownerToken) in C:\Users\IssaccLee\Documents\GitHub\file-service\src\Mondol.FileService.Web\Controllers\UserFileController.cs:line 249 at lambda_method(Closure , Object ) at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult() at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at System.Threading.Tasks.ValueTask1.get_Result()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 27.4832ms 200 application/json; charset=utf-8

file-service on centos7.4 Image cropping failure.

Running environment :Centos7.4/ASP.NET CORE 2.2

DockerCommand : docker run --name file_service_api -d -v files_data:/publish/wwwroot/ --restart=always -p 8001:80 file_service_api:$image_version

private void ConvertImage(string srcFilePath, Mime srcMime, string dstFilePath,
ImageModifier dstImgMod)
{
var isSvg = false;
if (srcMime.ContentType == "image/svg+xml")
{
var oldSrcFilePath = srcFilePath;
srcFilePath = Path.Combine(srcFilePath, Guid.NewGuid().ToString("N") + ".svg");
File.Copy(oldSrcFilePath, srcFilePath, true);
isSvg = true;
Log.Info(msg: "进入image/svg+xml", isPushMQ: true);
}

        try
        {
            //命令行参考:http://elf8848.iteye.com/blog/382528
            var opt = _option.CurrentValue;
            var pArgs = string.Empty;
            if (dstImgMod.Size != ImageSize.Raw)
            {
                var size = dstImgMod.Size;
                if (size.Width < 1 && size.Height < 1)
                    throw new InvalidOperationException("宽与高不能同时小于1");

                var widthStr = size.Width > 0 ? size.Width.ToString() : "";
                var heightStr = size.Height > 0 ? size.Height.ToString() : "";
                var resizeArgs = RexVar.Replace(_option.CurrentValue.ResizeArgs, m =>
                {
                    var varName = m.Groups[1].Value;
                    switch (varName)
                    {
                        case "width":
                            return widthStr;
                        case "height":
                            return heightStr;
                        default:
                            return m.Value;
                    }
                });

                pArgs += RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? string.Format("-resize '{0}'", resizeArgs) : "-resize \"" + resizeArgs + "\"";
            }

            pArgs += $" \"{srcFilePath}\" \"{dstFilePath}\"";
            var pArgs2 = Path.Combine(srcFilePath, dstFilePath);
            var timeoutSec = opt.ConvertTimeout * 1000;

            try
            {
                //pArgs=-resize '64x64>' "/publish/wwwroot/files/2019/09/21/3e49/25_31/raw" "/publish/wwwroot/files/2019/09/21/3e49/25_31/image_64x64_jpg.cvting.jpg"
                var exitCode = ProcessUtil.ExecuteCommand(opt.ConverterPath, pArgs, out var stdOut, out var errOut, timeoutSec);
                if (exitCode != 0)
                {
                    Log.Info(msg: "convert fail, exitCode=" + exitCode, isPushMQ: true);
                    throw new InvalidOperationException("convert fail, exitCode=" + exitCode);
                }
            }
            catch (Exception ex)
            {
                Log.Error(msg: ex.Message, ex: ex, isPushMQ: true);
                throw ex;
            }

        }
        catch (Exception ex)
        {
            try
            {
                File.Delete(dstFilePath);
            }
            catch
            {
            }
            throw ex;
        }
        finally
        {
            if (isSvg)
                try
                {
                    File.Delete(srcFilePath);
                }
                catch
                {

                }
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.