Here is my attachment loop to convert into Salesforce Files. The document as Files is created along with the title and content type however it has no content or sometimes '1' or 'MQ==' which is not expected. Any help would be appreciated.
for(Attachment att : attachtoupdate) {
ContentVersion cv = new ContentVersion();
cv.ContentLocation = 'S';
cv.PathOnClient =att.Name;
cv.Origin = 'H';
cv.OwnerId = att.OwnerId;
cv.Title = att.Name;
cv.VersionData = att.body;
// cv.VersionData = Blob.valueOf(EncodingUtil.base64Encode(att.body));
/* String fileContent = att.body!=Null ?
string.valueOf(att.Body).replaceAll('<','<')
.replaceAll('>','>')
.replaceAll('&','&')
.replaceAll('"','"')
.replaceAll('[',''')
.replaceAll('\'', '''):'.';*/
cv.FirstPublishLocationId = att.ParentId;
attachmentCVs.put(att.Id,cv);
attachmentParentIds.put(att.Id,att.ParentId);
attdelete.add(att);