Skip to content

Commit

Permalink
Add a validation step to fail and notify the user that the provided r…
Browse files Browse the repository at this point in the history
…esource will cause an issue
  • Loading branch information
johanmynhardt committed Sep 7, 2017
1 parent bb63009 commit 6613fc4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/afrozaar/wordpress/wpapi/v2/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ public <T> PagedResponse<T> search(SearchRequest<T> search) {
@SuppressWarnings("unchecked")
@Override
public Media createMedia(Media media, Resource resource) throws WpApiParsedException {
Objects.requireNonNull(resource.getFilename(), "The resource used to create a media item does not provide a filename. Please supply a Resource that overrides getFilename().");

try {
final MultiValueMap<String, Object> uploadMap = new LinkedMultiValueMap<>();
BiConsumer<String, Object> p = (index, value) -> ofNullable(value).ifPresent(v -> uploadMap.add(index, v));
Expand Down

0 comments on commit 6613fc4

Please sign in to comment.