i'm trying upload file sharepoint document library using c# csom library. document library i'm uploading has information rights management settings enforced.
when try upload file (either pdf document or word document - both without sort of protection applied), receive following error message:
this library not accept files of given type. must either upload new, unprotected file supports rights management or re-upload document downloaded library
i under impression both word documents , pdf documents supported rights management? i've tried manually uploading both files through sharepoint ui (to rule out problem files i'm using) , added document library without issues.
the code i'm using upload file shown below (it's pretty taken sample @ https://github.com/officedev/pnp/blob/master/samples/core.largefileupload/core.largefileupload/fileuploadservice.cs):
using (var ctx = getcontext(server)) { web web = ctx.web; ctx.load(web.lists, lists => lists.include(list => list.title, list => list.rootfolder)); ctx.executequery(); if (!listexists(ctx, web, listname)) { throw new invalidoperationexception($"the list '{listname}' not exist!"); } filecreationinformation newfile = new filecreationinformation { contentstream = filestream, url = path.getfilename(filename), overwrite = true }; list docs = web.lists.getbytitle(listname); microsoft.sharepoint.client.file uploadfile = docs.rootfolder.files.add(newfile); if (fileproperties != null && fileproperties.any()) { var listitem = uploadfile.listitemallfields; foreach (var fileproperty in fileproperties) { listitem[fileproperty.key] = fileproperty.value; } listitem.update(); } ctx.load(uploadfile); uploadfile.checkin("initial checkin", checkintype.majorcheckin); ctx.executequery(); }
is there step i'm missing?
after further investigation, seems problem caused due naming of uploaded file. file name used did not have file extension, must have bearing on irm protector sharepoint applies uploaded file (which seems obvious in hindsight!).
Comments
Post a Comment