Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4112248
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:10:15+00:00 2026-05-20T22:10:15+00:00

HI, Anyone suggest some sample and idea to post the video data to server.I

  • 0

HI,

Anyone suggest some sample and idea to post the video data to server.I want to playback the video later as stream video from the server directly.Anyone suggest me how to upload the stream video to php server and playback it as stream video from server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:10:16+00:00Added an answer on May 20, 2026 at 10:10 pm

    muniir@msn.com wrote:

    public class SocialHTTPPost 
    { 
        public static byte[] getCapturedImageStream(Context ctx, Intent data)
        {
            String fileName = ((MainActivity) ctx).mCaptureImageHMap.get("name").toString();
            int mid= fileName.lastIndexOf(".");
            String ext=fileName.substring(mid+1,fileName.length());
    
            Bundle b = data.getExtras();
            Bitmap bmp = (Bitmap) b.get("data");
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            if(ext.equalsIgnoreCase("png"))
                bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
            else if(ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg"))
                bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            byte[] bytes = stream.toByteArray();        
            return bytes;
        }
    
        public static void postImage(Context ctx, byte[] ba)
        {       
            String sid = ((MainActivity) ctx).mCaptureImageHMap.get("sid").toString();
    
            String ba1=Base64.encode(ba);
            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("image",ba1));
    
            for (Iterator iter = ((MainActivity) ctx).mCaptureImageHMap.entrySet().iterator(); iter.hasNext();) 
            {
                Map.Entry entry = (Map.Entry) iter.next();
                String key = (String)entry.getKey();
                String value = (String)entry.getValue();
                nameValuePairs.add(new BasicNameValuePair(key, value));
            }
    
            try
            {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(Config.MEDIA_IMAGE_PATH + "?AddFile=AddFile&SessionId=" + sid);
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                //is = entity.getContent();
            }
            catch(Exception e)
            {
                CommonFunctions.writeLOG(ctx.getClass().toString(), e.toString());
                CommonFunctions.showToast(ctx, "Unable to post captured image file: " + e.toString());
            }       
        }
    
        public static byte[] getCapturedVideoStream(Context ctx, Intent data)
        {       
            try 
            {
                AssetFileDescriptor videoAsset = ctx.getContentResolver().openAssetFileDescriptor(data.getData(), "r");
                FileInputStream fis = videoAsset.createInputStream();
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                byte[] buf = new byte[1024];
                try 
                {
                    for (int readNum; (readNum = fis.read(buf)) != -1;)                
                        bos.write(buf, 0, readNum);
                } 
                catch (IOException e) 
                {
                    CommonFunctions.writeLOG(CacheImagesManager.class.getClass().toString(), e.toString());
                }
                byte[] bytes = bos.toByteArray();
                return bytes;
            } 
            catch (IOException e) 
            {
                CommonFunctions.writeLOG(CacheImagesManager.class.getClass().toString(), e.toString());
                return null;
            }       
        }
    
        public static void postVideo(Context ctx, byte[] ba)
        {       
            String sid = ((MainActivity) ctx).mCaptureVideoHMap.get("sid").toString();
    
            String ba1=Base64.encode(ba);
            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("video",ba1));
    
            for (Iterator iter = ((MainActivity) ctx).mCaptureVideoHMap.entrySet().iterator(); iter.hasNext();) 
            {
                Map.Entry entry = (Map.Entry) iter.next();
                String key = (String)entry.getKey();
                String value = (String)entry.getValue();
                nameValuePairs.add(new BasicNameValuePair(key, value));
            }
    
            try
            {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(Config.MEDIA_VIDEO_PATH + "?AddFile=AddFile&SessionId=" + sid);
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                //HttpEntity entity = response.getEntity();
            }
            catch(Exception e)
            {
                CommonFunctions.writeLOG(ctx.getClass().toString(), e.toString());
                CommonFunctions.showToast(ctx, "Unable to post captured video file: "  + e.toString());
            }       
        }
    
        //  //////////////////////////////////////////  SAMPLE TEST START FOR READING WRITING IMAGES AND VIDEO BINARY
    
        public static boolean writeCaptureVideo(Context ctx, Intent data)
        {       
            String fileName = ((MainActivity) ctx).mCaptureImageHMap.get("name").toString();
            String sid = ((MainActivity) ctx).mCaptureImageHMap.get("sid").toString();
            String path = ""; //((MainActivity) ctx).mMediaPath;
    
            try 
            {
                AssetFileDescriptor videoAsset = ctx.getContentResolver().openAssetFileDescriptor(data.getData(), "r");
                FileInputStream fis = videoAsset.createInputStream();           
                File tmpFile = new File(path, fileName); 
                FileOutputStream fos = new FileOutputStream(tmpFile);
                byte[] buf = new byte[1024];
                int len;
                while ((len = fis.read(buf)) > 0) 
                {
                    fos.write(buf, 0, len);
                }       
                fis.close();
                fos.close();
                return true;
            } 
            catch (IOException e) 
            {
                CommonFunctions.writeLOG(CacheImagesManager.class.getClass().toString(), e.toString());
                return false;
            }       
        }
    
        public static boolean writeCaptureImage(Context ctx, Intent data)
        {
            String fileName = ((MainActivity) ctx).mCaptureImageHMap.get("name").toString();
            String path = ""; //((MainActivity) ctx).mMediaPath;
    
            int mid= fileName.lastIndexOf(".");
            String ext=fileName.substring(mid+1,fileName.length());
            File file = new File(path, fileName);
            Uri outputFileUri = Uri.fromFile( file );
            Bundle b = data.getExtras();
            Bitmap bm = (Bitmap) b.get("data");
    
            try 
            {               
                if(ext.equalsIgnoreCase("png"))
                    bm.compress(CompressFormat.PNG, 100, new FileOutputStream(file));
                else if(ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg"))
                    bm.compress(CompressFormat.JPEG, 100, new FileOutputStream(file));
                try {
                    Runtime.getRuntime().exec("chmod 777 " + path + "/" + fileName);
                } catch (IOException e1){}
    
                return true;
            } 
            catch (FileNotFoundException e) 
            {
                CommonFunctions.writeLOG(CacheImagesManager.class.getClass().toString(), e.toString());
                return false;
            }       
        }
    
        public static void postImage2(Context ctx)
        {
            //help site:    http://blog.sptechnolab.com/2011/03/09/android/android-upload-image-to-server/
            String fileName = ((MainActivity) ctx).mCaptureImageHMap.get("name").toString();
            String sid = ((MainActivity) ctx).mCaptureImageHMap.get("sid").toString();
            String path = ""; //((MainActivity) ctx).mMediaPath;
    
            int mid= fileName.lastIndexOf(".");             
            String ext=fileName.substring(mid+1,fileName.length());
    
            //InputStream is;
            Bitmap bitmapOrg = BitmapFactory.decodeFile(path + "/" + fileName);
            ByteArrayOutputStream bao = new ByteArrayOutputStream();
    
            if(ext.equalsIgnoreCase("png"))
                bitmapOrg.compress(Bitmap.CompressFormat.PNG, 100, bao);
            else if(ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg"))
                bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 100, bao);
    
            byte [] ba = bao.toByteArray();
            String ba1=Base64.encode(ba);
            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("image",ba1));
    
            for (Iterator iter = ((MainActivity) ctx).mCaptureImageHMap.entrySet().iterator(); iter.hasNext();) 
            {
                Map.Entry entry = (Map.Entry) iter.next();
                String key = (String)entry.getKey();
                String value = (String)entry.getValue();
                nameValuePairs.add(new BasicNameValuePair(key, value));
            }       
    
            try
            {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(Config.MEDIA_IMAGE_PATH + "?AddFile=AddFile&SessionId=" + sid );
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                //is = entity.getContent();
            }
            catch(Exception e)
            {
                CommonFunctions.writeLOG(ctx.getClass().toString(), e.toString());
                CommonFunctions.showToast(ctx, "Unable to post captured image file: " + fileName);
            }       
        }
    
        //  //////////////////////////////////////////  SAMPLE TEST END
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone suggest some sample to upload a video from the SD card to a
Can anyone suggest some good browser add-on tools/extensions to help with development? I have
Can anyone suggest some best options to include charting feature in my ASP.NET pages
Can anyone suggest some good materials for learning more about the Linux filesystem and
can anyone suggest me some good tutorials on Lucene. I was reading Lucene in
Could anyone suggest books or materials to learn unit test? Some people consider codes
I have written some thing like this to fetch data from the database. public
Can anyone suggest me a helpful programming language which can be used to create
Can anyone suggest a way of getting version information into a Web Service? (VB.NET)
Can anyone suggest a good source control system that interfaces with VB2005 Express? As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.