final Hidden auth = new Hidden("X-Auth-Token", "");
panel.add(auth);
- upload.setName("file");
+ upload.setName("X-Object-Data");
filenameLabel.setText("");
filenameLabel.setVisible(false);
filenameLabel.setStyleName("props-labels");
// Unfortunately the results are never empty, even in
// the absense of errors, so we have to check for '<pre></pre>'.
- if (results != null && !results.equalsIgnoreCase("<pre></pre>")) {
+ if (results != null && results.length() > 0 && !results.equalsIgnoreCase("<pre></pre>")) {
GWT.log(results, null);
app.displayError(results);
}
filenameLabel.setVisible(true);
if (getFileForName(fname) == null) {
- doUpload(apath);
+ form.submit();
}
else {
// We are going to update an existing file, so show a confirmation dialog.
}
}
- private void doUpload(String path) {
- PutRequest createFile = new PutRequest(path) {
- @Override
- public void onSuccess(Resource result) {
- form.submit();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("", t);
- if (t instanceof RestException) {
- app.displayError("Unable to create file:" + ((RestException) t).getHttpStatusText());
- }
- else
- app.displayError("System error creating file:" + t.getMessage());
- }
- };
- createFile.setHeader("X-Auth-Token", app.getToken());
- createFile.setHeader("Content-Length", "0");
- Scheduler.get().scheduleDeferred(createFile);
- }
-
/**
* Returns the file name from a potential full path argument. Apparently IE
* insists on sending the full path name of a file when uploading, forcing