Java: Delete an uploaded file using DeleteUploadedFile()
Download our Java samples from this page.
Find this sample in directory /test/com/postalmethods/client
Find this sample in directory /test/com/postalmethods/client
package com.postalmethods.client; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import com.postalmethods.client.api.DeleteUploadedFileResponse; import com.postalmethods.client.api.UploadFileResponse; /** * Integration test that calls the DeleteUploadedFile web method. * <p> * For details about PostalMethods.DeleteUploadFile see * <a href="http://www.postalmethods.com/method/2009-02-26/DeleteUploadedFile">the PostalMethods.DeleteUploadedFile reference</a> */ public class DeleteUploadedFileTest { private PostalMethodsClient client; @Before public void setUp() { client = new PostalMethodsClientFactory().build(); // Upload a sample file so we have something to delete. System.out.println("Making call to UploadFile..."); String description = "This is only a test."; UploadFileResponse response = client.uploadFile(TestConstants.SAMPLE_UPLOAD_FILE, TestConstants.SAMPLE_POSTCARD_IMAGE_FRONT_LOCAL, "User", description, true); System.out.println("Service call completed:\n" + response.getResult().toString()); int code = response.getResult().getCode(); assertEquals(-3000, code); // success } @Test public void testDeleteUploadedFile() { System.out.println("Making call to DeleteUploadedFile..."); DeleteUploadedFileResponse response = client.deleteUploadedFile(TestConstants.SAMPLE_UPLOAD_FILE); System.out.println("Service call completed:\n" + response.getResult().toString()); int code = response.getResult().getCode(); assertEquals(-3000, code); // success } }

