public async Task <bool> GetCoverImage(string imgUrl)
        {
            bool   result   = false;
            string fileName = System.IO.Path.GetFileName(imgUrl);

            if (!string.IsNullOrEmpty(fileName))
            {
                string pathToMediaFile = Path.Combine(ImagePathManager.GetPicturesDirectory(), fileName);
                if (!File.Exists(pathToMediaFile))
                {
                    try
                    {
                        result = await _serverRequest.HttpRequestGetFile(imgUrl, pathToMediaFile, _authToken);

                        LastHttpStatusCode = _serverRequest.GetLastStatusCode();
                        if (LastHttpStatusCode != HttpStatusCode.OK)
                        {
                            UserDialogs.Instance.Toast("Error downloading cover image");
                            HandleError.Process("FeedApiRequest", "GetCoverImage", new Exception(LastHttpStatusCode.ToString()), false, imgUrl);
                            deleteFile(pathToMediaFile);
                        }
                    }
                    catch (Exception e)
                    {
                        HandleError.Process("FeedApiRequest", "GetCoverImage", e, showWarning: false);
                        deleteFile(pathToMediaFile);
                    }
                }
            }
            return(result);
        }
        public async Task <bool> DownloadCoverImage(string routeId, string imgFilename)
        {
            bool result = false;

            try
            {
                string pathToMediaFile = Path.Combine(ImagePathManager.GetPicturesDirectory(), imgFilename);
                result = await _serverRequest.HttpRequestGetFile($"/api/route/{routeId}/cover", pathToMediaFile, _authToken);

                LastHttpStatusCode = _serverRequest.GetLastStatusCode();
            }
            catch (Exception e)
            {
                HandleError.Process("RoutesApiRequest", "DownloadCoverImage", e, false);
            }
            return(result);
        }
Beispiel #3
0
        public async Task <bool> GetImage(string routePointId, string routePointMediaObjectId, string pathToPictures, string filename)
        {
            bool result = false;

            try
            {
                string pathToMediaFile = Path.Combine(pathToPictures, filename);
                result = await _serverRequest.HttpRequestGetFile($"/api/routepointmediaobjects/{routePointId}/{routePointMediaObjectId}/{filename}", pathToMediaFile, _authToken);

                LastHttpStatusCode = _serverRequest.GetLastStatusCode();
            }
            catch (Exception e)
            {
                HandleError.Process("RoutePointMediaObjectApiRequest", "GetFile", e, false);
            }
            return(result);
        }
        public async Task <bool> DownloadImg(string poiId, string pathToMediaFile)
        {
            bool result = false;

            try
            {
                string fileName = System.IO.Path.GetFileName(pathToMediaFile);
                result = await _serverRequest.HttpRequestGetFile($"/api/poi/{poiId}/image/{fileName}", pathToMediaFile, _authToken);

                LastHttpStatusCode = _serverRequest.GetLastStatusCode();
            }
            catch (Exception e)
            {
                HandleError.Process("PoiApiRequest", "DownloadImg", e, false);
            }
            return(result);
        }