Exemple #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            SPOWeb web = new SPOWeb(ctx.Site.OpenWeb(Web.Read()));

            WriteObject(web.GetFileByServerRelativeUrl(Url));
        }
        public SPOFile Read(SPOWeb spoWeb)
        {
            if (string.IsNullOrEmpty(_serverRelativeUrl))
            {
                throw new ArgumentNullException("The server relative URL was not provided.");
            }

            return(spoWeb.GetFileByServerRelativeUrl(_serverRelativeUrl));
        }
Exemple #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            ctx.Load(ctx.Site, s => s.ServerRelativeUrl);
            ctx.ExecuteQuery();

            FileInfo file     = new FileInfo(LiteralPath);
            string   leafName = file.Name;
            string   url      = ctx.Site.ServerRelativeUrl.TrimEnd('/') + "/_catalogs/solutions/" + leafName;

            using (FileStream stream = new FileStream(LiteralPath, FileMode.Open))
            {
                Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx,
                                                                  url, stream, Overwrite);
            }
            SPOWeb web = new SPOWeb(ctx.Site.RootWeb);

            WriteObject(web.GetFileByServerRelativeUrl(url));
        }