Esempio n. 1
0
        MediaObjectInfo IMetaWeblog.NewMediaObject(string blogid, string username, string password,
            MediaObject mediaObject)
        {
            LocatePortal(Context.Request);

            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui.UserID > 0)
            {
                var objectInfo = new MediaObjectInfo();

                string name = mediaObject.name; //object name
                var media = mediaObject.bits;   //object body

                //Save media object to filesystem. Split name with '/' to extract filename (Windows Live Writer specific)
                int index = name.LastIndexOf('/');
                Directory.CreateDirectory(Utility.GetThumbnailLibraryMapPath(PortalId).AbsolutePath + name.Substring(0, index));
                FileStream stream = File.Create(Utility.GetThumbnailLibraryMapPath(PortalId).AbsolutePath + name);
                stream.Write(media, 0, media.Length);
                stream.Flush();
                stream.Close();
                stream.Dispose();
                objectInfo.url = Utility.GetThumbnailLibraryPath(PortalId) + name;
                return objectInfo;
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
Esempio n. 2
0
        MediaObjectInfo IMetaWeblog.NewMediaObject(string blogid, string username, string password, MediaObject mediaObject)
        {
            return(LogExceptions(() =>
            {
                this.LocatePortal(this.Context.Request);

                DotNetNuke.Entities.Users.UserInfo ui = this.Authenticate(username, password);
                if (ui.UserID > 0)
                {
                    var objectInfo = new MediaObjectInfo();

                    string name = mediaObject.name; // object name
                    var media = mediaObject.bits;   // object body

                    // Save media object to filesystem. Split name with '/' to extract filename (Windows Live Writer specific)
                    int index = name.LastIndexOf('/');
                    Directory.CreateDirectory(Utility.GetThumbnailLibraryMapPath(PortalId).LocalPath + name.Substring(0, index));
                    FileStream stream = File.Create(Utility.GetThumbnailLibraryMapPath(PortalId).LocalPath + name);
                    stream.Write(media, 0, media.Length);
                    stream.Flush();
                    stream.Close();
                    stream.Dispose();
                    objectInfo.url = Utility.GetThumbnailLibraryPath(PortalId) + name;
                    return objectInfo;
                }

                throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", this.LocalResourceFile));
            }));
        }