コード例 #1
0
ファイル: Api.cs プロジェクト: efdalyilmaz/InstaBot
        public async Task UploadPhotoAsync(string stockCategoryName, int photoCount, IDownloadService downloadService)
        {
            List <string> downloadedPhotos = downloadService.GetAllDownloadedPhotoNames();
            List <Photo>  photoList        = await stockService.SearchNewPhotosAsync(stockCategoryName, photoCount, downloadedPhotos);

            await downloadService.DownloadAllPhotosAsync(photoList);

            downloadService.WriteDownloadedPhotoNames(photoList);

            int uploadedPhoto = 1;

            logger.Write(String.Format("Downloaded photo count {0}", photoList.Count));
            foreach (var photo in photoList)
            {
                string filePath = FileUtils.GetFullFilePath(downloadService.FullDirectory, photo.Id, ApiConstans.PHOTO_EXTENSION);
                await instaService.UploadPhotoAsync(filePath, photo.GetCaption());

                logger.Write(String.Format("{0}. uploaded. PhotoId : {1} ", uploadedPhoto, photo.Id));
                uploadedPhoto++;
            }
        }