首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Convert.FromBase64String升级后v14无法工作

Convert.FromBase64String升级后v14无法工作
EN

Stack Overflow用户
提问于 2022-09-27 16:15:08
回答 1查看 19关注 0票数 0

我们刚刚将我们的2sxc自定义API升级为v14,现在我们在一个API控制器中遇到了一个问题,该控制器用于将文件从Base64转换为字节数组来上传文件。下面是代码:

代码语言:javascript
复制
public class IntegrationApiController : Custom.Hybrid.Api14
{
    [HttpPost]
    public string UploadPdf([FromBody] dynamic bodyJson)
    {
        var entity = new Dictionary<string, object>();
        var guid = Guid.NewGuid();
        entity.Add("EntityGuid", guid);
        App.Data.Create("PDFForm", entity);
        var data = Convert.FromBase64String(bodyJson.file.ToString());
        var returnThing = SaveInAdam(stream: new MemoryStream(data), fileName: bodyJson.fileName.ToString(), contentType: "PDFForm", guid: guid, field: "File");
        
        return returnThing.Url;
    }
}

我们现在得到以下错误:

代码语言:javascript
复制
{
    "Message": "2sxc Api Controller Finder Error: Error selecting / compiling an API controller. Check event-log, code and inner exception. ",
    "ExceptionMessage": "c:\\Websites\\Mainstar\\Portals\\0\\2sxc\\DocusignForms\\api\\IntegrationApiController.cs(26): error CS1061: 'ToSic.Sxc.Services.IConvertService' does not contain a definition for 'FromBase64String' and no extension method 'FromBase64String' accepting a first argument of type 'ToSic.Sxc.Services.IConvertService' could be found (are you missing a using directive or an assembly reference?)",
    "ExceptionType": "System.Web.HttpCompileException",
    "StackTrace": "   at System.Web.Compilation.AssemblyBuilder.Compile()\r\n   at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()\r\n   at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)\r\n   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)\r\n   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)\r\n   at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)\r\n   at System.Web.Compilation.BuildManager.GetCompiledAssembly(String virtualPath)\r\n   at ToSic.Sxc.Dnn.WebApiRouting.AppApiControllerSelector.HttpControllerDescriptor(HttpRequestMessage request, String controllerFolder, String controllerPath, String controllerTypeName, LogCall`1 wrapLog) in C:\\Projects\\2sxc\\2sxc\\Src\\Dnn\\ToSic.Sxc.Dnn.WebApi\\Dnn\\WebApiRouting\\AppApiControllerSelector.cs:line 168\r\n   at ToSic.Sxc.Dnn.WebApiRouting.AppApiControllerSelector.SelectController(HttpRequestMessage request) in C:\\Projects\\2sxc\\2sxc\\Src\\Dnn\\ToSic.Sxc.Dnn.WebApi\\Dnn\\WebApiRouting\\AppApiControllerSelector.cs:line 83"
}

有什么办法解决这个问题吗?我确实尝试过将"Convert.FromBase64String“更改为"System.Convert.FromBase64String”,但这并没有解决问题--我得到了一个“无法对空引用执行运行时绑定”的错误。

任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

发布于 2022-09-28 14:06:56

System.Convert...听起来是对的。而国际水文学组织应该发挥作用。

我猜您的bodyJsonbodyJson.file是空的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73870725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档