Jump to content

C# adding people primary images in the Person Metadata interface


mickle026

Recommended Posts

mickle026

Ive had issues with this before and am still having issues

All of my metadata is updating properly (date of birth, location, overview etc) so I know Im returning the person object ...   but my images are not setting or showing up

It is downloading and is in the location it is supposed to be!

The interface

        public async Task<MetadataResult<Person>> GetMetadata(PersonLookupInfo info, CancellationToken cancellationToken)
        {
            MetadataResult<Person> personMetaInfo = GetPersonDetails(info);

            return personMetaInfo;
        }

and so my primary image is now located in a sub folder in the cache directory, the path is held in DownloadTo

MetadataResult<Person> GetPersonDetails(PersonLookupInfo info)
{
	var result = new MetadataResult<Person>();
	var newPerson = new Person();
  
  // code to set locations and get json data into a DecodedJson object
  
    using (WebClient client = new WebClient())
	{
		client.DownloadFile(ImageUrl, DownloadTo);
	}
  
	List<FileSystemMetadata> img = new List<FileSystemMetadata>
	{
	new FileSystemMetadata
		{
			FullName = DownloadTo,
			DirectoryName = Path.GetDirectoryName(DownloadTo)
		}
	};

	newPerson.AddImages(ImageType.Primary, img, false);
  
 	newPerson.Overview = DecodedJson.Overview ?? string.Empty;
  // more code
  
  
	result.HasMetadata = true;

	result.Item = newPerson;

	return result;
  }

Can anyone see what I am doing wrong here ? - Im not an expert but i think its probably something in this code.

 

List<FileSystemMetadata> img = new List<FileSystemMetadata>
	{
	new FileSystemMetadata
		{
			FullName = DownloadTo,
			DirectoryName = Path.GetDirectoryName(DownloadTo)
		}
	};

Thanks

Link to comment
Share on other sites

hi, I would suggest using a normal image provider rather than setting it that way. please try that.

Link to comment
Share on other sites

mickle026
19 hours ago, Luke said:

hi, I would suggest using a normal image provider rather than setting it that way. please try that.

Thanks, I have infact done that with a remote image provider interface.

I wish i didnt have to do that , as i have to look them up twice on my server, seems a waste of resources.

 

However, I would like to know why the code above doesn't work.

Link to comment
Share on other sites

IT's a property made for local metadata providers. It's not used in other cases. The remote image provider is the right answer. Then you just give it the url and the core server will handle the downloading.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...