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

  • Home
  • SEARCH
  • 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 6700049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:46:05+00:00 2026-05-26T06:46:05+00:00

I have a task. Upload on http server part of a file (I must

  • 0

I have a task. Upload on http server part of a file (I must skip beginning of the file).

How can I do it. Do you know good solution?

Can I use my own solution? Is it safe?

My solution. I made subclass of FileEntity that gives file stream and skips beginning of the file.

  1. I put my entity to request.

    HttpPut request = new HttpPut(this.uri);

    request.setEntity(new FileOfsetEntity(new File(getDestination()), “binary/octet-stream”, ofset));

  2. My FileOfsetEntity skips begining of the file.

    class FileOfsetEntity extends FileEntity {
    
    long ofset = 0;
    public FileOfsetEntity(File file, String contentType, long ofset) {
      super(file, contentType);
      this.ofset = ofset;
    }
    @Override
    public long getContentLength() {
      return this.file.length() - ofset;
    }
    @Override
    public InputStream getContent() throws IOException {
      FileInputStream in = new FileInputStream(this.file);
      long skiped = in.skip(ofset);
      Log.w("FileOfsetEntity.getContent","skiped = " + skiped);
      return in;
    }
    @Override
    public void writeTo(final OutputStream outstream) throws IOException {
      if (outstream == null) {
          throw new IllegalArgumentException("Output stream may not be null");
      }
      InputStream instream = new FileInputStream(this.file);
      long skiped = instream.skip(ofset);
      Log.w("FileOfsetEntity.writeTo","skiped = " + skiped);
      try {
          byte[] tmp = new byte[4096];
          int l;
          long readed = skiped;
          while ((l = instream.read(tmp)) != -1) {
              readed += l;
              outstream.write(tmp, 0, l);
              Log.v("FileOfsetEntity.writeTo",file.getAbsolutePath() + " readed = " + readed + " skiped = " + skiped);
          }
          outstream.flush();
      } finally {
          instream.close();
      } }}
    
  • 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-26T06:46:06+00:00Added an answer on May 26, 2026 at 6:46 am

    I am not sure this may fail or go through.

    I would suggest, a different way of doing this. I presume that you know the office before uploading.

    Here is a link to upload file to server.

    In this code, move your offset and then start writing it into the stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the task of choosing an XMPP server/client solution for an internal web
i having task to upload file to Web application server, when test with local
I have failed submission (can't even get past upload verification) because my background agent
I am facing the task of having to upload a snapshot to the server.
I have files that I want to delete. Connection can be from file sharing,
I have the necessity to upload some photos to my server (giving users the
I have a large file I'm uploading. The entire request can take more than
I have created a function to upload a file using this library as follows:
I have a web app where users can upload files. The files are physically
I am new this sharepoint development and i have task in hand to do

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.