I've read quite a few posts about file upload, and tested the moebious forms app, but I can't quite figure how file upload works.
What is the relation between the adam folder name and the entity guid/id?
Could you help create a simple app demo that demonstrates the single file upload feature? For us newbs it's way easier to integrate features without complex environments working around it.
using DotNetNuke.Security;
using DotNetNuke.Web.Api;
using System.Web.Http;
using ToSic.SexyContent.WebApi;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Web.Compilation;
using System.Runtime.CompilerServices;
using DotNetNuke.Services.Mail;
using Newtonsoft.Json;
using System.IO;
public class fileController : SxcApiController
{
[HttpPost]
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Anonymous)]
[ValidateAntiForgeryToken]
public void ProcessForm([FromBody]Dictionary<string,object> contactFormRequest)
{
contactFormRequest = new Dictionary<string, object>(contactFormRequest, StringComparer.OrdinalIgnoreCase);
var guid = Guid.NewGuid();
contactFormRequest.Add("EntityGuid", guid);
App.Data.Create("demoData", contactFormRequest);
var files = new List<ToSic.Sxc.Adam.IFile>();
foreach(var file in ((Newtonsoft.Json.Linq.JArray)contactFormRequest["Files"]).ToObject<IEnumerable<Dictionary<string, string>>>())
{
var data = Convert.FromBase64String((file["Encoded"]).Split(',')[1]);
files.Add(SaveInAdam(stream: new MemoryStream(data), fileName: file["Name"], contentType: "demoData", guid: guid, field: file["Field"]));
}
}
}
I've read quite a few posts about file upload, and tested the moebious forms app, but I can't quite figure how file upload works.
What is the relation between the adam folder name and the entity guid/id?
Could you help create a simple app demo that demonstrates the single file upload feature? For us newbs it's way easier to integrate features without complex environments working around it.
Here's a headstart:
view:
controller: