예제 #1
0
        public File GetFileById(object id)
        {
            var key  = "spointf-" + MakeId(id);
            var file = SharePointProviderInfoHelper.GetFile(key);

            if (file == null)
            {
                file = GetFile(id);
                if (file != null)
                {
                    SharePointProviderInfoHelper.AddFile(key, file);
                }
            }
            return(file);
        }
예제 #2
0
        public File CreateFile(string id, Stream stream)
        {
            byte[] b;

            using (var br = new BinaryReader(stream))
            {
                b = br.ReadBytes((int)stream.Length);
            }

            var file = clientContext.Web.RootFolder.Files.Add(new FileCreationInformation {
                Content = b, Url = id, Overwrite = true
            });

            clientContext.Load(file);
            clientContext.Load(file.ListItemAllFields);
            clientContext.ExecuteQuery();

            SharePointProviderInfoHelper.AddFile("spointf-" + MakeId(id), file);
            SharePointProviderInfoHelper.PublishFolder(MakeId(GetParentFolderId(id)));

            return(file);
        }