Hello
It is posible to save a file in creatio from a base64 string? I have a web service that allows me to request a document by an id to an external service and it responds with the document in a base64 string, so I would like to know if it is possible to convert that string into the file and save it in some record on the platform.
Thank you
Like
2 comments
18:08 Aug 15, 2024
Something like this should work:
var base64FileString = Get<string>("Base64File"); var accountId = Get<Guid>("AccountId"); var attachFileType = new Guid("529bc2f8-0ee0-df11-971b-001d60e938c6"); var fileName = "SomeFile.docx" // set proper file type in file name var entity = UserConnection.EntitySchemaManager.GetInstanceByName("AccountFile"); var fileEntity = entity.CreateEntity(UserConnection); fileEntity.SetDefColumnValues(); fileEntity.SetColumnValue("AccountId", accountId); fileEntity.SetColumnValue("TypeId", attachFileType); fileEntity.SetColumnValue("Name",fileName); fileEntity.SetBytesValue("Data", Convert.FromBase64String(base64FileString)); fileEntity.Save();
Ryan
Show all comments