How to: Remove media that failed in upload
We can inspect and correct this information using SQL queries.
Show failed media
The following query will show all media that for some reason failed in the upload. We can see this by inspecting the MediaItemStateId.
This is a bitwise flag that determines the state of the media.
| flag | Description |
| 0 | Item is registered in the db. | | 1 | Meta data Is analyzed | | 2 | Media is stored in the target storage | | 4 | Organized by user |
The mediaItems with MediaStateId 7 will be displayed in the photo stream and are the only ones that will be available for usage.
The mediaItems with MediaStateId 3 are analyzed and stored but not organized by a user yet. All these media files can be organized by navigating to the http://site.com/ImageVault/Organize URL.
All other states are in progress, either in analysis or storage.
Filter out missing media
The following SQL statement will filter out all media that isn't ready to use or unorganized
select * from MediaItems where MediaItemStateId NOT IN (7,3) AND deleted=0
From this list you can select the items that you want to Delete.
Deleting failed media
There are two methods that will delete a media item. Either mark the items in the database as deleted or remove them completely from the system.
In this example you will see how to mark items as deleted.
Mark a MediaItem as deleted
The MediaItems defines all media entered in ImageVault. This table has a column named deleted that indicates if the media is deleted or not. If deleted these media will be "invisible" from the API.
To mark a MediaItem as deleted, run the following SQL command and replace x with the id of the MediaItem that you want to mark as deleted.
UPDATE MediaItems SET Deleted=1 WHERE MediaItemId=x
Mark a MediaContentReference as deleted
The MediaContentReferences table contains all conversions for all medias and we can mark a specific item as deleted as well.
To mark all conversions for a specific MediaItem as deleted, run the following SQL command and replace x with the id of the MediaItem that you want to mark as deleted.
UPDATE MediaContentReferences SET Deleted=1 WHERE MediaItemId=x
When you have marked the failed media as deleted, they will no longer be part of the FileWatcher Job that tries to store the media. You don't have to restart the service for this operation since this information has not been cached. If you on the other hand, mark other files (files with MediaItemStateId 3 or 7) then you have to restart the core service(s) to get them to reload their cache.