cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to delete a file from FileRepository in Java extension?

sclifford
1-Newbie

How to delete a file from FileRepository in Java extension?

I have a Java extension where I need to write a service that deletes a specified file from MyCustomFileRepository.

But the DeleteFile method isn't available as part of the FileRepositoryThing class!

@ThingworxServiceDefinition(name = "DeleteFile", description = "Deletes the specified file from the Healthband FileRepository entity.", category = "", isAllowOverride = false, aspects = {"isAsync:false" })

@ThingworxServiceResult(name = "Result", description = "", baseType = "STRING", aspects = {})

public String DeleteFile(

        @ThingworxServiceParameter(name = "filePath", description = "", baseType = "STRING", aspects = {"isRequired:true" }) String filePath) {

    final FileRepositoryThing repo = (FileRepositoryThing) ThingUtilities.findThing("MyCustomFileRepository");

    repo.DeleteFile(filePath);

    return "";

}

}


1 ACCEPTED SOLUTION

Accepted Solutions
jkaczynski
4-Participant
(To:sclifford)

Hello Shane Clifford​,

Please let us know, what version of Thingworx Extension SDK do you use? I've just tested it on 7.0 and it's working fine.

Regards,

J.

View solution in original post

3 REPLIES 3
jkaczynski
4-Participant
(To:sclifford)

Hello Shane Clifford​,

Please let us know, what version of Thingworx Extension SDK do you use? I've just tested it on 7.0 and it's working fine.

Regards,

J.

Hello Jakub,

I'm developing for 6.6.0 instances, so using 6.6.0 Thingworx Extension SDK.

Thanks,

Shane

Yes, tested and confirmed FileDelete method is present in the ThingWorx Extension SDK 7.2.3 version of FileRepository class. Marking your answer as correct Jakub, thank you.

Top Tags