Exemplo n.º 1
0
        public MediaObjectInfo NewMediaObject(string blogid, string username, string password, MediaObject mediaObject)
        {
            if (ValidateUser(username, password))
            {
                // WLR sends images with the name "imge.png". Very resourcefull
                var objectInfo = new MediaObjectInfo();

                // image
                using (var memoryStream = new MemoryStream(mediaObject.bits))
                {
                    var fileName = Path.GetFileNameWithoutExtension(mediaObject.name) + "_" + DateTime.Now.Ticks + Path.GetExtension(mediaObject.name);

                    fileRepository.Save(memoryStream, fileName, false);
                    objectInfo.url = new Uri(HttpContext.Current.Request.GetOriginalUrl(), "/get/" + fileName.TrimStart('/')).ToString();
                }

                return(objectInfo);
            }
            throw new XmlRpcFaultException(0, "User is not valid!");
        }
Exemplo n.º 2
0
        public MediaObjectInfo NewMediaObject(string blogid, string username, string password, MediaObject mediaObject)
        {
            Exception exception;
            if (!IsValidUser(username, password, out exception))
            {
                throw exception;
            }

            // WLR sends images with the name "imge.png". Very resourcefull
            var objectInfo = new MediaObjectInfo();

            // image
            using (var memoryStream = new MemoryStream(mediaObject.bits))
            {
                var fileName = Path.GetFileNameWithoutExtension(mediaObject.name) + "_" + DateTime.Now.Ticks +
                                             Path.GetExtension(mediaObject.name);

                fileRepository.Save(memoryStream, fileName, false);
                objectInfo.url = new Uri(HttpContext.Current.Request.GetOriginalUrl(), "/get/" + fileName.TrimStart('/')).ToString();
            }

            return objectInfo;
        }
Exemplo n.º 3
0
        public MediaObjectInfo NewMediaObject(string blogid, string username, string password,
            MediaObject mediaObject)
        {
            if (ValidateUser(username, password))
            {	// WLR sends images with the name "imge.png". Very resourcefull
                var objectInfo = new MediaObjectInfo();

                // image
                using (var memoryStream = new MemoryStream(mediaObject.bits))
                {
                    var fileName = Path.GetFileNameWithoutExtension(mediaObject.name) + "_" + DateTime.Now.Ticks + Path.GetExtension(mediaObject.name);

                    objectInfo.url = VirtualPathUtility.ToAbsolute(funnelWebSettings.UploadPath + "/" + fileName);

                    fileRepository.Save(memoryStream, fileName, false);
                }

                return objectInfo;
            }
            throw new XmlRpcFaultException(0, "User is not valid!");
        }