[PlayFramework]Blob with @Required saves File twice
Model like :
@Entity
public class Doc extends Model {
public Blob tpl;
}
Controller like:
public class DocController extends Controller {
public static void saveDoc(@Required Blob tpl){
render(); // event no persistence oper开发者_运维百科ation
}
}
It will have 2 uploaded file in the data/attachments. even there are no persistence operation in the controller action.
You can pass the Doc object directly into your action (use doc.tpl
from the view, rather than just tpl
), and then perform the validation on the Object, rather than the Blob itself.
@Entity
public class Doc extends Model {
@Required
public Blob tpl;
}
public class DocController extends Controller {
public static void saveDoc(@Valid Doc doc){
render(); // event no persistence operation
}
}
精彩评论