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 992561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:17:16+00:00 2026-05-16T06:17:16+00:00

Reading more than 1mb of data from a BlobstoreInputStream will throw an IOException Blob

  • 0

Reading more than 1mb of data from a BlobstoreInputStream will throw an IOException “Blob fetch size too large.”

You can use the ChainedBlobstoreInputStream class in the answer below to solve this problem.

  • 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-16T06:17:17+00:00Added an answer on May 16, 2026 at 6:17 am

    I’ve created a simple wrapper class that solves this problem. You should be able to directly swap ChainedBlobstoreInputStream for BlobstoreInputStream. I haven’t tested the mark(), markSupported() or reset() methods.

    You may use this code however you wish.

    package net.magicscroll.server.blobstore;
    
    import com.google.appengine.api.blobstore.BlobInfo;
    import com.google.appengine.api.blobstore.BlobInfoFactory;
    import com.google.appengine.api.blobstore.BlobKey;
    import com.google.appengine.api.blobstore.BlobstoreInputStream;
    
    import java.io.IOException;
    import java.io.InputStream;
    
    /**
     * ChainedBlobstoreInputStream works exactly like BlobstoreInputStream but does
     * not throw an error if more than 1mb is read.
     * 
     * @author Richard Wallis
     */
    public class ChainedBlobstoreInputStream extends InputStream {
        /**
         * The maximum number of bytes that can be read by a single request.
         */
        private static final int MAX_READSIZE = 1015800;
    
        /**
         * The BlobKey of the blobstore item.
         */
        private BlobKey blobKey;
        /**
         * The current byte position of the reader.
         */
        private long offset;
    
        /**
         * The Total Size of the blob.
         */
        private long totalSize;
        /**
         * The current Input Stream being read.
         */
        private BlobstoreInputStream currentStream;
        /**
         * The next point at which a new InputStream will need to be initialized.
         */
        private long nextReadBreak;
        /**
         * The currentStream at the time of the last mark.
         */
        private BlobstoreInputStream markedStream;
    
        /**
         * Creates a new ChainedBlobstoreInputStream. This stream should behave
         * exactly the same as a BlobstoreInputStream and it should be possible to
         * interchange them.
         * 
         * @param theBlobKey
         *            - The blobkey of the object to be read.
         * @throws IOException
         *             - Thrown if there is an error reading the current stream.
         */
        public ChainedBlobstoreInputStream(final BlobKey theBlobKey)
                throws IOException {
            this(theBlobKey, 0);
        }
    
        /**
         * Creates a new ChainedBlobstoreInputStream. This stream should behave
         * exactly the same as a BlobstoreInputStream and it should be possible to
         * interchange them.
         * 
         * @param theBlobKey
         *            - The blobkey of the object to be read.
         * @param newOffset
         *            - The offset in the blob from where to read.
         * @throws IOException
         *             - Thrown if there is an error reading the current stream.
         */
        public ChainedBlobstoreInputStream(final BlobKey theBlobKey,
                final long newOffset) throws IOException {
            this.offset = newOffset;
            this.blobKey = theBlobKey;
            final BlobInfo blobInfo = 
                new BlobInfoFactory().loadBlobInfo(this.blobKey);
            this.totalSize = blobInfo.getSize();
            this.currentStream = 
                new BlobstoreInputStream(this.blobKey, this.offset);
            this.nextReadBreak = 
                this.offset + ChainedBlobstoreInputStream.MAX_READSIZE;
        }
    
        /*
         * (non-Javadoc)
         * @see java.io.InputStream#read()
         */
        @Override
        public final int read() throws IOException {
            if (this.offset < this.totalSize) {
                if (this.offset == this.nextReadBreak) {
                    this.currentStream.close();
                    this.currentStream = 
                        new BlobstoreInputStream(this.blobKey, this.offset);
                    this.nextReadBreak = this.offset 
                    + ChainedBlobstoreInputStream.MAX_READSIZE;
                }
                this.offset += 1;
                return this.currentStream.read();
            } else {
                this.currentStream.close();
                return -1;
            }
        }
    
        /*
         * (non-Javadoc)
         * @see java.io.InputStream#close()
         */
        @Override
        public final void close() throws IOException {
            this.currentStream.close();
            super.close();
        }
    
        /*
         * (non-Javadoc)
         * @see java.io.InputStream#mark(int)
         */
        @Override
        public final void mark(final int readlimit) {
            this.currentStream.mark(readlimit);
            this.markedStream = this.currentStream;
        }
    
        /*
         * (non-Javadoc)
         * @see java.io.InputStream#markSupported()
         */
        @Override
        public final boolean markSupported() {
            return this.currentStream.markSupported();
        }
    
        /*
         * (non-Javadoc)
         * @see java.io.InputStream#reset()
         */
        @Override
        public final void reset() throws IOException {
            this.currentStream = this.markedStream;
            this.currentStream.reset();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some logic/programming help with reading more than one record from a text
I'm looking at solutions to a problem that involves reading keyed data from more
Ive been reading from several sources, and now Im more confused then ever. So
Java is reading the locale, timezone and encoding information (and perhaps more) from the
Error reading XSLT file: \xslt\umbTopNavigation.xslt i've tried installing on more than one server -everyone
have been away from Android for more than a year, trying to pick up
I have been reading C++ and writing small programs in it for more than
I have a client serever application, My server accepts connections from more than one
Are DataContracts in WCF nothing more than DTOs? I was reading up about WCF
Having more than one process read from a serial device (/dev/ttyXX) makes it so

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.