private boolean InitializeComponents(Intent intent)
{
cr = getContentResolver();
context = new BasicHttpContext();
if (android.os.Build.VERSION.SDK_INT >= 11) {
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
/* Get Settings Begin */
SharedPreferences preferences = getSharedPreferences("de.desy.dCacheCloud_preferences", Context.MODE_PRIVATE);
target.add(preferences.getString("webdav_url", null));
String user = preferences.getString("webdav_user", null);
String password = preferences.getString("webdav_password", null);
/* Get Settings End */
/*
if (target.get(target.size()-1) == null) {
Log.d("dCache", "No URL set up.");
return false;
}
*/
// Get Extras from Intend-Loader
fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
File sdCard = Environment.getExternalStorageDirectory();
fileUri = Uri.parse(String.format("file://%s/%s/%s", sdCard.getAbsolutePath(), "dCacheCloud/.enc", fileUri.getLastPathSegment()));
// File fileOutput = new File(sdCard, String.format("dCacheCloud/%s", CryptoHelper.hash(fileUri.getLastPathSegment())));
Log.d("davsync", "Uploading " + fileUri.toString());
filename = fileUri.getLastPathSegment();
if (filename == null) {
Log.d("dCache", "fileName returned null");
return false;
}
setFileHandling();
try {
httpClient = ServerHelper.getClient();
} catch (GeneralSecurityException e) {
Log.d("SECURITY", String.format("General Security Error: %s", e.toString()));
e.printStackTrace();
} catch (IOException e1) {
Log.d("Unknown", String.format("Error: %s", e1.toString()));
e1.printStackTrace();
}
httpClient.setRedirectHandler(new DefaultRedirectHandler() {
@Override
public URI getLocationURI(HttpResponse response, HttpContext contet) throws org.apache.http.ProtocolException {
Log.d("Rederection!!: ", Arrays.toString(response.getHeaders("Location")));
System.out.println(Arrays.toString(response.getHeaders("Location")));
target.add(Arrays.toString(response.getHeaders("Location")));
isRedirected = true;
return super.getLocationURI(response, context);
}
});
httpPut = new HttpPut();
httpPut.setEntity(entity);
ServerHelper.setCredentials(httpClient, httpPut, user, password);
return true;
}
UploadService.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:dCache-Cloud
作者:
评论列表
文章目录