Пример #1
0
        public IHttpActionResult Get()
        {
            var          client  = StorageAuthentication.GetUserCredentials();
            DriveService service = StorageAuthentication.AuthenticateOauth(client.ClientId, client.ClientSecret, "root");

            string q            = "mimeType = 'application/vnd.google-apps.photo'";
            var    newsPictures = StorageOperation.GetFiles(service, q);

            return(this.Ok(newsPictures));
        }
Пример #2
0
        public IHttpActionResult Post(NewsArticleRequestModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            ////var client = StorageAuthentication.GetUserCredentials();
            ////DriveService service = StorageAuthentication.AuthenticateOauth(client.ClientId, client.ClientSecret, "root");
            var imagesCollection = model.Images;

            if (imagesCollection != null)
            {
                var          client  = StorageAuthentication.GetUserCredentials();
                DriveService service = StorageAuthentication.AuthenticateOauth(client.ClientId, client.ClientSecret, "root");
            }

            //// the case when image files are uploaded and saved on server hdd (Article should be referenced)
            ////foreach (var image in imagesCollection)
            ////{
            ////    var upload = StorageOperation.UploadFile(service, image.Name, StorageOperation.ParentFolder);
            ////    image.Url = string.Format("https://drive.google.com/uc?id={0}", upload.Id);
            ////}
            //
            //// the case when image files are byte arrays
            ////foreach (var image in imagesCollection)
            ////{
            ////    var upload = StorageOperation.UploadFile(service, new byte[100], StorageOperation.ParentFolder);
            ////    image.Url = string.Format("https://drive.google.com/uc?id={0}", upload.Id);
            ////}
            var dataModel = Mapper.Map <NewsArticle>(model);

            var newArticleId = this.newsArticles.Add(dataModel, this.User.Identity.Name);

            this.pubnub.SendNotification(NotifyConstants.PubnubChannelActivityFeed, string.Format("News article {0} created", dataModel.Name));

            return(this.Ok(newArticleId));
        }