You need to sign in to do that
Don't have an account?
Raghu Madaan 6
Adding file in ContentVersion via Apex shows Duplicate Entry in Storage Usage - Content
Hello Everyone,
I am trying to create a ContentVersion Object via Apex and adding a ContentDocumentLink with CommunityId as LinkEntityId . This uploads file very well and Shows a single file in "Files" Tab. But the issue is - It is getting recorded as double the size in Storage Usage for File Storage and the "Record Count" column always makes 2 entries and incremented by 2 rather then 1 (if i upload a file using Files tab).
Same is happening with the other Scenario i tried. Created ContentVersion Object and now rather then creating ContentDocumentLink i now created ContentDistribution. Still it is recorded as double the actual file size and Record Count is increment by 2.
Now the more problem arises is : When i delete the ContentDocument Object only 1 entry is decremented in "Record Count" and File Storage space is decremented by the actual file size. And now my storage limit Exceeded as the Extra Object created by salesforce is not getting delete either and there is no option to delete it either.Emptied Recycled Bin also.
I am trying to create a ContentVersion Object via Apex and adding a ContentDocumentLink with CommunityId as LinkEntityId . This uploads file very well and Shows a single file in "Files" Tab. But the issue is - It is getting recorded as double the size in Storage Usage for File Storage and the "Record Count" column always makes 2 entries and incremented by 2 rather then 1 (if i upload a file using Files tab).
Same is happening with the other Scenario i tried. Created ContentVersion Object and now rather then creating ContentDocumentLink i now created ContentDistribution. Still it is recorded as double the actual file size and Record Count is increment by 2.
Now the more problem arises is : When i delete the ContentDocument Object only 1 entry is decremented in "Record Count" and File Storage space is decremented by the actual file size. And now my storage limit Exceeded as the Extra Object created by salesforce is not getting delete either and there is no option to delete it either.Emptied Recycled Bin also.
Can you please try creating manually in the UI as well and check if the issue still exists?
Thanks,
Shashank
I tried the same thing with UI by first creating a file and then creating a Content Delivery for it. This is not happening from the UI. From UI only one entry is coming in the storage Record UI count and file size is not saving as double the actual size.
Thanks,
Raghu
Here you GO!!!
ContentVersion contentVersion = new ContentVersion();
contentVersion.PathOnClient = 'X_FILE_NAME.png';
contentVersion.VersionData = 'X_FILE_BLOB';//Please add any Blob data which is good in size(~500KB) so you can find the double size
contentVersion.Origin = 'H';
contentVersion.NetworkId = 'X_COMMUNITY_ID'; //You Need to Enable Communities for using this and get the communityIs from Network Object or hardcode it from from salesforce URL
insert contentVersion;
ContentDistribution contentDistribution = new ContentDistribution();
contentDistribution.ContentVersionId = contentVersion.Id;
contentDistribution.Name = 'X_FILE_NAME.png';
contentDistribution.PreferencesAllowOriginalDownload = true;
contentDistribution.PreferencesAllowPDFDownload = true;
contentDistribution.PreferencesAllowViewInBrowser = true;
contentDistribution.PreferencesLinkLatestVersion = true;
contentDistribution.PreferencesNotifyOnVisit = false;
insert contentDistribution;
This really seems to be strange thing because this is not happening with me in the UI. If it is reflecting as 2 records in your UI also, does it also decrements to 2 after deleting that file.?
No actually that is not my scenario which i need. Have you tried doing it with code rather than UI..?
Are you looking for large file Storage in Salesforce..?
We got a solution for you…!
Here you may be interested in knowing about appexchange native app Cloud Drop which is having this feature.
For more details check:
http://www.clouddrop.io
Check Out the following URL for application:
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IzEDEA0
Regards,
Kumar Saurav