From e53fdfdd78538a21cddd45b9d3faa1a7e9e37a0a Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期五, 21 七月 2023 13:36:24 +0800
Subject: [PATCH] 修改附件
---
force-app/main/default/classes/eSignAgencyConfirmPageController.cls | 58 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/force-app/main/default/classes/eSignAgencyConfirmPageController.cls b/force-app/main/default/classes/eSignAgencyConfirmPageController.cls
index da7e851..4d43060 100644
--- a/force-app/main/default/classes/eSignAgencyConfirmPageController.cls
+++ b/force-app/main/default/classes/eSignAgencyConfirmPageController.cls
@@ -255,42 +255,62 @@
public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
+ ContentVersion version = new ContentVersion();
+ version.VersionData = EncodingUtil.base64Decode(base64Data);
+ version.Title = fileName;
+ version.PathOnClient = fileName + contentType;
+ version.ContentLocation = 's';
+ insert version;
+ version = [select Id,ContentDocumentId from ContentVersion where Id =: version.Id];
+ ContentDocumentLink link = new ContentDocumentLink();
+ link.LinkedEntityId = parentId;
+ link.ContentDocumentId = version.ContentDocumentId;
+ link.Visibility = 'AllUsers';
+ link.ShareType = 'I';
+ insert link;
+
+ // Attachment oAttachment = new Attachment();
+ // oAttachment.parentId = parentId;
- Attachment oAttachment = new Attachment();
- oAttachment.parentId = parentId;
+ // oAttachment.Body = EncodingUtil.base64Decode(base64Data);
+ // oAttachment.Name = fileName;
+ // oAttachment.ContentType = contentType;
- oAttachment.Body = EncodingUtil.base64Decode(base64Data);
- oAttachment.Name = fileName;
- oAttachment.ContentType = contentType;
+ // insert oAttachment;
- insert oAttachment;
-
- return oAttachment.Id;
+ return link.ContentDocumentId;
}
private static void appendToFile(Id fileId, String base64Data) {
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
- Attachment a = [
- SELECT Id, Body
- FROM Attachment
- WHERE Id =: fileId
+ // Attachment a = [
+ // SELECT Id, Body
+ // FROM Attachment
+ // WHERE Id =: fileId
+ // ];
+ ContentVersion version = [
+ select
+ Id,
+ VersionData
+ from ContentVersion where ContentDocumentId =: fileId
];
+ String existingBody = EncodingUtil.base64Encode(version.VersionData);
- String existingBody = EncodingUtil.base64Encode(a.Body);
+ version.VersionData = EncodingUtil.base64Decode(existingBody + base64Data);
- a.Body = EncodingUtil.base64Decode(existingBody + base64Data);
-
- update a;
+ update version;
}
//鏂囦欢鍒犻櫎鍔熻兘 绮剧悽鎶�鏈� thh 2021-09-26 start
@AuraEnabled
public static void deleteChunk(Id AttachmentId) {
- Attachment attachment = new Attachment();
- attachment.id = AttachmentId;
+ // Attachment attachment = new Attachment();
+ // attachment.id = AttachmentId;
+ ContentDocument con = new ContentDocument();
+ con.Id = AttachmentId;
- delete attachment;
+ delete con;
}
//鏂囦欢鍒犻櫎鍔熻兘 绮剧悽鎶�鏈� thh 2021-09-26 end
}
\ No newline at end of file
--
Gitblit v1.9.1