retrofit.http.Multipart Java Examples

The following examples show how to use retrofit.http.Multipart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatrulatrulAPI.java    From patrol-android with GNU General Public License v3.0 6 votes vote down vote up
@Multipart
@Headers({"Content-Type: multipart/form-data",
        "Accept: application/json",
        "Accept-Encoding: gzip, deflate"})
@POST("/api/{userID}/violation/create")
VideoAnswer uploadImage(@Part("photo") TypedFile photo,
                        @EncodedPath("userID") String userID,
                        @Part("latitude") double latitude,
                        @Part("longitude") double longitude);
 
Example #2
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/meals/{xid}/partialUpdate")
void updateMealEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @Path(UpPlatformSdkConstants.XID) String xid,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #3
Source File: DrupalOAuth2.java    From drupalfit with MIT License 5 votes vote down vote up
@Multipart
@POST("/token")
Observable<Credential> observeToken(
    @Part("client_id") String clientId,
    @Part("client_secret") String clientSecret,
    @Part("grant_type") String grantType,
    @Part("state") String state,
    @Part("username") String username,
    @Part("password") String password
);
 
Example #4
Source File: DrupalOAuth2.java    From drupalfit with MIT License 5 votes vote down vote up
@Multipart
@POST("/token")
Credential token(
    @Part("client_id") String clientId,
    @Part("client_secret") String clientSecret,
    @Part("grant_type") String grantType,
    @Part("state") String state,
    @Part("username") String username,
    @Part("password") String password
);
 
Example #5
Source File: DrupalOAuth2.java    From drupalfit with MIT License 5 votes vote down vote up
/**
 * <pre>
 * curl -k -X POST 'https://example.com/oauth2/token' -d 'grant_type=password&client_id=id&client_secret=secret&state=state&username=foo&password=bar'
 * </pre>
 */
@Multipart
@POST("/token")
void token(
    @Part("client_id") String clientId,
    @Part("client_secret") String clientSecret,
    @Part("grant_type") String grantType,
    @Part("state") String state,
    @Part("username") String username,
    @Part("password") String password,
    Callback<Credential> callback
);
 
Example #6
Source File: DrupalOAuth2.java    From drupalfit with MIT License 5 votes vote down vote up
@Multipart
@POST("/token")
Observable<Credential> observeToken(
    @Part("code") String code,
    @Part("client_id") String clientId,
    @Part("client_secret") String clientSecret,
    @Part("grant_type") String grantType,
    @Part("state") String state
);
 
Example #7
Source File: DrupalOAuth2.java    From drupalfit with MIT License 5 votes vote down vote up
@Multipart
@POST("/token")
Credential token(
    @Part("code") String code,
    @Part("client_id") String clientId,
    @Part("client_secret") String clientSecret,
    @Part("grant_type") String grantType,
    @Part("state") String state
);
 
Example #8
Source File: DrupalOAuth2.java    From drupalfit with MIT License 5 votes vote down vote up
/**
 * <pre>
 * curl -k -X POST 'https://example.com/oauth2/token' -d 'code=aa5b25e58cb0ecbb1ddf5d671e769b04cabcdefg&state=8tory&grant_type=authorization_code&client_id=id&client_secret=secret'
 * </pre>
 */
@Multipart
@POST("/token")
void token(
    @Part("code") String code,
    @Part("client_id") String clientId,
    @Part("client_secret") String clientSecret,
    @Part("grant_type") String grantType,
    @Part("state") String state,
    Callback<Credential> callback
);
 
Example #9
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/refreshToken")
void getRefreshToken(
        @Path(UpPlatformSdkConstants.API_VERSION) String version,
        @Part("secret") String clientSecret,
        Callback<Object> response
);
 
Example #10
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/mood")
void createMoodEvent(
        @Path(UpPlatformSdkConstants.API_VERSION) String version,
        @PartMap HashMap<String, Object> hashMap,
        Callback<Object> response
);
 
Example #11
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/goals")
void createOrUpdateUsersGoals(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #12
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/body_events")
void createBodyEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #13
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/sleeps")
void createSleepEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #14
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/workouts/{xid}/partialUpdate")
void updateWorkoutEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #15
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/workouts")
void createWorkoutEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #16
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/generic_events/{xid}/partialUpdate")
void updateCustomEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #17
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/generic_events")
void createCustomEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #18
Source File: RestApiInterface.java    From UPPlatform_Android_SDK with Apache License 2.0 5 votes vote down vote up
@Multipart
@POST("/nudge/api/{version}/users/@me/meals")
void createMealEvent(
    @Path(UpPlatformSdkConstants.API_VERSION) String version,
    @PartMap HashMap<String, Object> hashMap,
    Callback<Object> response
);
 
Example #19
Source File: ServerAPI.java    From FlowGeek with GNU General Public License v2.0 5 votes vote down vote up
@Multipart
@POST("/action/api/tweet_pub")
Call<RespResult> publicTweet(
        @Part("uid") RequestBody uid,
        @Part("msg") RequestBody message,
        @Part("img\"; filename=\"image.png\" ") RequestBody image,
        @Part("amr") RequestBody voice);
 
Example #20
Source File: UploadApi.java    From talk-android with MIT License 4 votes vote down vote up
@Multipart
@POST("/upload")
Observable<FileUploadResponseData> uploadFile(@Part("name") String name, @Part("type") String mimeType, @Part("size") long fileSize, @Part("file") TypedFile file);
 
Example #21
Source File: RestMethodInfo.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
/**
 * Loads {@link #requestMethod} and {@link #requestType}.
 */
private void parseMethodAnnotations() {
    for (Annotation methodAnnotation : method.getAnnotations()) {
        Class<? extends Annotation> annotationType = methodAnnotation.annotationType();
        RestMethod methodInfo = null;

        // Look for a @RestMethod annotation on the parameter annotation indicating request method.
        for (Annotation innerAnnotation : annotationType.getAnnotations()) {
            if (RestMethod.class == innerAnnotation.annotationType()) {
                methodInfo = (RestMethod) innerAnnotation;
                break;
            }
        }

        if (methodInfo != null) {
            if (requestMethod != null) {
                throw new IllegalArgumentException("Method " + method.getName() + " contains multiple HTTP methods. Found: " + requestMethod + " and " + methodInfo.value());
            }
            String path;
            try {
                path = (String) annotationType.getMethod("value").invoke(methodAnnotation);
            } catch (Exception e) {
                throw new RuntimeException("Failed to extract path from " + annotationType.getSimpleName() + " annotation on " + method.getName() + ".", e);
            }
            parsePath(path);
            requestMethod = methodInfo.value();
            requestHasBody = methodInfo.hasBody();
        } else if (annotationType == Headers.class) {
            String[] headersToParse = ((Headers) methodAnnotation).value();
            if (headersToParse.length == 0) {
                throw new IllegalStateException("Headers annotation was empty.");
            }
            headers = parseHeaders(headersToParse);
        } else if (annotationType == Multipart.class) {
            if (requestType != RequestType.SIMPLE) {
                throw new IllegalStateException("Only one encoding annotation per method is allowed: " + method.getName());
            }
            requestType = RequestType.MULTIPART;
        } else if (annotationType == FormUrlEncoded.class) {
            if (requestType != RequestType.SIMPLE) {
                throw new IllegalStateException("Only one encoding annotation per method is allowed: " + method.getName());
            }
            requestType = RequestType.FORM_URL_ENCODED;
        }
    }

    if (requestMethod == null) {
        throw new IllegalStateException("Method " + method.getName() + " not annotated with request type (e.g., GET, POST).");
    }
    if (!requestHasBody) {
        if (requestType == RequestType.MULTIPART) {
            throw new IllegalStateException("Multipart can only be specific on HTTP methods with request body (e.g., POST). (" + method.getName() + ")");
        }
        if (requestType == RequestType.FORM_URL_ENCODED) {
            throw new IllegalStateException("Multipart can only be specific on HTTP methods with request body (e.g., POST). (" + method.getName() + ")");
        }
    }
}
 
Example #22
Source File: ApiDefs.java    From spark-sdk-android with Apache License 2.0 4 votes vote down vote up
@Multipart
@PUT("/v1/devices/{deviceID}")
Response flashFile(@Path("deviceID") String deviceID,
                   @Part("file") TypedOutput file);
 
Example #23
Source File: VideoSvcApi.java    From mobilecloud-15 with Apache License 2.0 4 votes vote down vote up
@Multipart
@POST(VIDEO_DATA_PATH)
public VideoStatus setVideoData(@Path(ID_PARAMETER) long id, @Part(DATA_PARAMETER) TypedFile videoData);
 
Example #24
Source File: HockeyApp.java    From foam with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Multipart
@POST("/api/2/apps/{APP_ID}/crashes/upload")
void createEvent(@Path("APP_ID") String appId,
                 @Part("log") TypedFile log,
                 Callback<Response> callback
);
 
Example #25
Source File: ApiService.java    From droidddle with Apache License 2.0 4 votes vote down vote up
@Multipart
@POST("/shots")
Observable<Response> createShot(@Part("image") TypedFile image, @Part("title") TypedString title, @Part("description") TypedString description, @Part("tags") TypedString tags);
 
Example #26
Source File: ApiService.java    From droidddle with Apache License 2.0 4 votes vote down vote up
@Multipart
@POST("/shots")
Observable<Response> createShot(@Part("image") TypedFile image, @Part("title") TypedString title, @Part("description") TypedString description);
 
Example #27
Source File: ApiService.java    From droidddle with Apache License 2.0 4 votes vote down vote up
@Multipart
@POST("/shots/{id}/attachments")
Observable<Response> createShotAttachments(@Path("id") long id, @Part("file") TypedFile file);
 
Example #28
Source File: UploadAppToRepoRequest.java    From aptoide-client with GNU General Public License v2.0 4 votes vote down vote up
@POST("/upload.webservices.aptoide.com/webservices/2/uploadAppToRepo")
@Multipart
UploadAppToRepoJson postApk(@PartMap HashMap<String, Object> args);
 
Example #29
Source File: PagesService.java    From Android-REST-API-Explorer with MIT License 3 votes vote down vote up
/**
 * Creates a new page with a multi-part content body
 * in a section specified by section id
 *
 * @param version
 * @param sectionId
 * @param partMap
 * @param callback
 */
@Multipart
@POST("/{version}/me/notes/sections/{sectionId}/pages")
void postMultiPartPages(
        @Path("version") String version,
        @Path("sectionId") String sectionId,
        @PartMap OneNotePartsMap partMap,
        Callback<Envelope<Page>> callback
);
 
Example #30
Source File: VideoSvcApi.java    From mobilecloud-15 with Apache License 2.0 2 votes vote down vote up
/**
 * This endpoint allows clients to set the mpeg video data for previously
 * added Video objects by sending multipart POST requests to the server.
 * The URL that the POST requests should be sent to includes the ID of the
 * Video that the data should be associated with (e.g., replace {id} in
 * the url /video/{id}/data with a valid ID of a video, such as /video/1/data
 * -- assuming that "1" is a valid ID of a video). 
 * 
 * @return
 */
@Multipart
@POST(VIDEO_DATA_PATH)
public VideoStatus setVideoData(@Path(ID_PARAMETER) long id, @Part(DATA_PARAMETER) TypedFile videoData);