FlickrNet.Flickr.PhotosSetPerms C# (CSharp) Method

PhotosSetPerms() public method

Set the permissions on a photo.
public PhotosSetPerms ( string photoId, bool isPublic, bool isFriend, bool isFamily, PermissionComment permComment, PermissionAddMeta permAddMeta ) : void
photoId string The id of the photo to update.
isPublic bool True if the photo is public, False if it is not.
isFriend bool True if the photo is viewable by friends, False if it is not.
isFamily bool True if the photo is viewable by family, False if it is not.
permComment PermissionComment Who can add comments. See for more details.
permAddMeta PermissionAddMeta Who can add metadata (notes and tags). See for more details.
return void
        public void PhotosSetPerms(string photoId, bool isPublic, bool isFriend, bool isFamily, PermissionComment permComment, PermissionAddMeta permAddMeta)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.photos.setPerms");
            parameters.Add("photo_id", photoId);
            parameters.Add("is_public", (isPublic?"1":"0"));
            parameters.Add("is_friend", (isFriend?"1":"0"));
            parameters.Add("is_family", (isFamily?"1":"0"));
            parameters.Add("perm_comment", permComment.ToString("d"));
            parameters.Add("perm_addmeta", permAddMeta.ToString("d"));

            FlickrNet.Response response = GetResponseNoCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                return;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }

Same methods

Flickr::PhotosSetPerms ( string photoId, int isPublic, int isFriend, int isFamily, PermissionComment permComment, PermissionAddMeta permAddMeta ) : void

Usage Example

Exemplo n.º 1
0
        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