Android Open Source - connexus-android Upload Image






From Project

Back to project page connexus-android.

License

The source code is released under:

Apache License

If you think the Android project connexus-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

/*
 * Copyright (C) 2013 Zach Whaley, Trevor Latson
 */* www. ja v  a  2 s .c om*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ginger.connexus.network;

import ginger.connexus.model.ConnexusImage;

import java.io.File;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.http.Path;
import retrofit.mime.TypedFile;

public class UploadImage {
    private static final String API_URL = "http://connexus-api.appspot.com";

    interface UploadApi {
        @Multipart
        @POST("/_ah/upload/{path1}/{path2}/")
        void uploadImage(@Path("path1") String path1, @Path("path2") String path2,
                @Part("stream") long stream,
                @Part("latitude") float latitude,
                @Part("longitude") float longitude,
                @Part("image") TypedFile image,
                Callback<ConnexusImage> cb);
    }

    private final String uploadurl;
    private final long stream;
    private final float latitude;
    private final float longitude;
    private final TypedFile image;
    private final Callback<ConnexusImage> callback;

    public UploadImage(String uploadUrl, long streamId, float lat, float lng, File file, Callback<ConnexusImage> cb) {
        this.uploadurl = uploadUrl;
        this.stream = streamId;
        this.latitude = lat;
        this.longitude = lng;
        this.image = new TypedFile("image/jpg", file);
        this.callback = cb;
    }

    public void post() {
        RestAdapter restAdapter = new RestAdapter.Builder()
                .setServer(API_URL)
                .build();

        UploadApi upload = restAdapter.create(UploadApi.class);
        String[] paths = uploadurl.split("/");
        upload.uploadImage(paths[0], paths[1], stream, latitude, longitude, image, callback);
    }

}




Java Source Code List

android.UnusedStub.java
ginger.connexus.Connexus.java
ginger.connexus.activity.AuthActivity.java
ginger.connexus.activity.BaseActivity.java
ginger.connexus.activity.ImageDetailActivity.java
ginger.connexus.activity.ImageGridActivity.java
ginger.connexus.activity.MainActivity.java
ginger.connexus.activity.SearchableActivity.java
ginger.connexus.adapter.ImageAdapter.java
ginger.connexus.fragment.ChooseAccountFragment.java
ginger.connexus.fragment.GridFragment.java
ginger.connexus.fragment.ImageDetailFragment.java
ginger.connexus.fragment.ImageGridFragment.java
ginger.connexus.fragment.SpiceFragment.java
ginger.connexus.fragment.StreamGridFragment.java
ginger.connexus.model.ConnexusImage.java
ginger.connexus.model.ConnexusStream.java
ginger.connexus.network.ConnexusApi.java
ginger.connexus.network.RequestAllStreams.java
ginger.connexus.network.RequestNearbyStreams.java
ginger.connexus.network.RequestStreamImages.java
ginger.connexus.network.RequestSubscribedStreams.java
ginger.connexus.network.RequestUploadURL.java
ginger.connexus.network.UploadImage.java
ginger.connexus.service.ConnexusService.java
ginger.connexus.ui.RecyclingBitmapDrawable.java
ginger.connexus.ui.RecyclingImageView.java
ginger.connexus.util.AccountUtils.java
ginger.connexus.util.AsyncTask.java
ginger.connexus.util.DiskLruCache.java
ginger.connexus.util.ImageCache.java
ginger.connexus.util.ImageFetcher.java
ginger.connexus.util.ImageResizer.java
ginger.connexus.util.ImageWorker.java
ginger.connexus.util.Images.java
ginger.connexus.util.Utils.java