All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mongodb.client.gridfs.GridFSUploadStream Maven / Gradle / Ivy

Go to download

The MongoDB Java Driver uber-artifact, containing mongodb-driver, mongodb-driver-core, and bson

The newest version!
/*
 * Copyright 2015 MongoDB, Inc.
 *
 * 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 com.mongodb.client.gridfs;

import com.mongodb.annotations.NotThreadSafe;
import org.bson.types.ObjectId;

import java.io.OutputStream;

/**
 * A GridFS OutputStream for uploading data into GridFS
 *
 * 

Provides the {@code id} for the file to be uploaded as well as the {@code write} methods of a {@link OutputStream}

* *

This implementation of a {@code OutputStream} will not throw {@link java.io.IOException}s. However, it will throw a * {@link com.mongodb.MongoException} if there is an error writing to MongoDB.

* * @since 3.1 */ @NotThreadSafe public abstract class GridFSUploadStream extends OutputStream { /** * Gets the {@link ObjectId} for the file to be uploaded * * @return the ObjectId for the file to be uploaded */ public abstract ObjectId getFileId(); /** * Aborts the upload and deletes any data. */ public abstract void abort(); @Override public abstract void write(int b); @Override public abstract void write(byte[] b); @Override public abstract void write(byte[] b, int off, int len); @Override public void flush() {} @Override public abstract void close(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy