FlickrNet.Flickr.PhotosGetPerms C# (CSharp) Méthode

PhotosGetPerms() public méthode

Get permissions for a photo.
public PhotosGetPerms ( string photoId ) : PhotoPermissions
photoId string The id of the photo to get permissions for.
Résultat PhotoPermissions
        public PhotoPermissions PhotosGetPerms(string photoId)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.photos.getPerms");
            parameters.Add("photo_id", photoId);

            FlickrNet.Response response = GetResponseCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                return new PhotoPermissions(response.AllElements[0]);
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }

Usage Example

        public Stream GetContents(DiscoveredFile file)
        {
            string photoId = file.Path.Split('/')[1];

            var perms = _flickr.PhotosGetPerms(photoId);

            if (!perms.IsPublic && file.Url.Contains("video_download"))
            {
                _flickr.PhotosSetPerms(photoId, true, perms.IsFriend, perms.IsFamily, perms.PermissionComment, perms.PermissionAddMeta);
            }

            try
            {
                using (WebClient wc = new WebClient())
                {
                    var stream = new MemoryStream(wc.DownloadData(file.Url));
                    return(stream);
                }
            }
            catch (Exception ex)
            {
                _userInteraction.ReportError(ex.Message);
                throw;
            }
            finally
            {
                if (!perms.IsPublic && file.Url.Contains("video_download"))
                {
                    _flickr.PhotosSetPerms(photoId, perms.IsPublic, perms.IsFriend, perms.IsFamily, perms.PermissionComment, perms.PermissionAddMeta);
                }
            }
        }
Flickr