Copyright (c) 2012 CloudMine LLC, http://cloudmine.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software")...
If you think the Android project cloudmine-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.cloudmine.api.rest;
/*www.java2s.com*/import com.android.volley.NetworkResponse;
import com.android.volley.Response;
import com.cloudmine.api.CMApiCredentials;
import com.cloudmine.api.CMFile;
import com.cloudmine.api.CMSessionToken;
import com.cloudmine.api.rest.options.CMServerFunction;
import com.cloudmine.api.rest.response.FileCreationResponse;
import me.cloudmine.annotations.Expand;
import me.cloudmine.annotations.Optional;
/**
* A Request for creating or updating a CMFile
* <br>
* Copyright CloudMine LLC. All rights reserved<br>
* See LICENSE file included with SDK for details.
*/publicclass BaseFileCreationRequest extends CloudMineRequest<FileCreationResponse> {
publicstaticfinalint REQUEST_TYPE = 400;
staticfinal String BASE_ENDPOINT = "";
staticfinal CMURLBuilder BASE_URL = new CMURLBuilder(BASE_ENDPOINT, true);
privatefinalbyte[] body;
privatefinal String contentType;
/**
* Create a new BaseFileCreationRequest
* @param file the file to be created or updated
* @param sessionToken optional session token, if this file belongs to a specific user
* @param serverFunction
* @param successListener
* @param errorListener
*/
@Expand
public BaseFileCreationRequest(CMFile file, @Optional CMSessionToken sessionToken, @Optional CMApiCredentials apiCredentials, @Optional CMServerFunction serverFunction, @Optional Response.Listener<FileCreationResponse> successListener, @Optional Response.ErrorListener errorListener) {
super(Method.PUT, BASE_URL.copy().user(sessionToken).binary(file.getFileId()).serverFunction(serverFunction).asUrlString(), null, sessionToken, apiCredentials, successListener, errorListener);
body = file.getFileContents();
contentType = file.getMimeType();
}
@Override
protected Response<FileCreationResponse> parseNetworkResponse(NetworkResponse networkResponse) {
return Response.success(new FileCreationResponse(new String(networkResponse.data), networkResponse.statusCode), getCacheEntry());
}
public String getBodyContentType() {
return contentType;
}
@Override
publicint getRequestType() {
return REQUEST_TYPE;
}
publicbyte[] getBody() {
return body;
}
}