Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- issue54: GridFS: Delete file and it's chunks by a given query

- issue57: gridfs download file throws exception that file is directory
  • Loading branch information...
commit 1ecda5ae20cfc4756c29afeaad9054452a025118 1 parent 2832181
@agirbal authored
View
7 resource/xml/JMongoBrowser.xml
@@ -228,6 +228,13 @@
</FileChooserField>
</FormDialog>
</MenuItem>
+ <MenuItem id="deleteFile" call="deleteFile">
+ <FormDialog id="deleteFileDialog">
+ <Text value="Specify a query object or a file name"/>
+ <org.mongo.jmongob.DocBuilderField id="deleteQuery" label="Query" toolTipText="Find the file using this query"/>
+ <TextField id="deleteFileName" label="File Name" toolTipText="Name of the file as stored on the server"/>
+ </FormDialog>
+ </MenuItem>
</Menu>
<Menu id="tools">
<MenuItem id="repair" call="repair"/>
View
45 src/org/mongo/jmongob/DbPanel.java
@@ -47,6 +47,9 @@
downloadQuery,
downloadFileName,
downloadFilePath,
+ deleteFile,
+ deleteQuery,
+ deleteFileName,
commandCmd,
commandStr,
commandJson,
@@ -204,12 +207,12 @@ public String getNS() {
@Override
public String getShortName() {
- return "Upload";
+ return "Upload File";
}
@Override
public Object getRoot(Object result) {
- return "path=" + path;
+ return " path=" + path;
}
@Override
@@ -230,7 +233,6 @@ public void downloadFile() {
return;
}
final File dfile = new File(dpath);
- dfile.mkdirs();
new DbJob() {
@@ -255,12 +257,45 @@ public String getNS() {
@Override
public String getShortName() {
- return "Download";
+ return "Download File";
}
@Override
public Object getRoot(Object result) {
- return "filename=" + fname + " path=" + dpath;
+ return "filename=" + fname + ", query=" + query + ", path=" + dpath;
+ }
+ }.addJob();
+ }
+
+ public void deleteFile() {
+ final DB db = getDbNode().getDb();
+ final DBObject query = ((DocBuilderField)getBoundUnit(Item.downloadQuery)).getDBObject();
+ final String fname = getStringFieldValue(Item.downloadFileName);
+
+ new DbJob() {
+
+ @Override
+ public Object doRun() throws IOException {
+ if (query != null)
+ getGridFS().remove(query);
+ else
+ getGridFS().remove(fname);
+ return true;
+ }
+
+ @Override
+ public String getNS() {
+ return db.getName();
+ }
+
+ @Override
+ public String getShortName() {
+ return "Delete File";
+ }
+
+ @Override
+ public Object getRoot(Object result) {
+ return "filename=" + fname + ", query=" + query;
}
}.addJob();
}

0 comments on commit 1ecda5a

Please sign in to comment.
Something went wrong with that request. Please try again.