Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Is it possible to create a Media Entity from a file in a File Repository?
I have attempted to access a File Repository's files through the REST API but don't think this is possible without executing RES API services of which I am unsure how to implement.
Is there a more simpler way of creating Media Entities from Images uploaded to a File Repository?
Many Thanks
Ashley
Solved! Go to Solution.
Hi Ashley,
For example, we have a FileRepository named ImageFile, with a folder "test" that contains an image "test". Then we have a Thing with a service "LoadFrom Rep". It contains the following service to load/access the image contained in the filerepository ImageFIle. This is the service (result output set to Image):
var params = {
path: '/test/test.jpg' /* STRING */
};
// result: IMAGE
var Content1= Things["ImageFIle"].LoadImage(params);
result=Content1;
Similarly, we may then expand the service to load that image to a media entity (in this scenario I'm creating a new entity):
var params = {
name: 'NewMedia' /* STRING */,
content: Content1 /* IMAGE */,
};
// no return
Resources["EntityServices"].CreateMediaEntity(params);
Hi Ashley,
For example, we have a FileRepository named ImageFile, with a folder "test" that contains an image "test". Then we have a Thing with a service "LoadFrom Rep". It contains the following service to load/access the image contained in the filerepository ImageFIle. This is the service (result output set to Image):
var params = {
path: '/test/test.jpg' /* STRING */
};
// result: IMAGE
var Content1= Things["ImageFIle"].LoadImage(params);
result=Content1;
Similarly, we may then expand the service to load that image to a media entity (in this scenario I'm creating a new entity):
var params = {
name: 'NewMedia' /* STRING */,
content: Content1 /* IMAGE */,
};
// no return
Resources["EntityServices"].CreateMediaEntity(params);
Hi Ashley,
Following Polina's steps, you can set the image Path, the image file Name and Media ThingName as three input to this service, and then you can use REST API calls to create more media entities from the image files remotely
Thank you Ryan.
Thank you for this Polina!