Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.appengine.api.files
Interface FileService

    public interface FileService

This is the interface for interacting with the Google App Engine File Service. A `FileService` instance is obtained via `FileServiceFactory.getFileService()`.

Method Summary
`AppEngineFile` | `createNewBlobFile(java.lang.String mimeType)` Creates a new empty file in the BlobStore of the specified mime-type and returns an `AppEngineFile` representing the file.
`AppEngineFile` | `createNewBlobFile(java.lang.String mimeType, java.lang.String blobInfoUploadedFileName)` Creates a new empty file in the BlobStore of the specified mime-type and returns an `AppEngineFile` representing the file.
`AppEngineFile` | `getBlobFile(BlobKey blobKey)` Given a `BlobKey` returns the corresponding `AppEngineFile`.
`BlobKey` | `getBlobKey(AppEngineFile file)` Given a `BLOBSTORE` file that has been finalized, returns the `BlobKey` for the corresponding blob.
`FileReadChannel` | `openReadChannel(AppEngineFile file, boolean lock)` Given an `AppEngineFile`, returns a `FileReadChannel` that may be used for reading bytes from the file.
`FileWriteChannel` | `openWriteChannel(AppEngineFile file, boolean lock)` Given an `AppEngineFile`, returns a `FileWriteChannel` that may be used for appending bytes to the file.

Method Detail

### createNewBlobFile

    AppEngineFile createNewBlobFile(java.lang.String mimeType)
                                    throws java.io.IOException

  Creates a new empty file in the BlobStore of the specified mime-type and returns an `AppEngineFile` representing the file. The returned instance will have a `file system` of `BLOBSTORE`.

  Parameters:
    `mimeType` - the mime-type of the file to be created. This parameter may be used to inform the BlobStore of the mime-type for the file. The mime-type will be returned by the BlobStore in an HTTP response if the file is requested directly from the BlobStore using the blob-key.
  Returns:
    A `AppEngineFile` representing the newly created file.
  Throws:
    `java.io.IOException` - If there is any problem communicating with the backend system

### createNewBlobFile

    AppEngineFile createNewBlobFile(java.lang.String mimeType,
                                    java.lang.String blobInfoUploadedFileName)
                                    throws java.io.IOException

  Creates a new empty file in the BlobStore of the specified mime-type and returns an `AppEngineFile` representing the file. The returned instance will have a `file system` of `BLOBSTORE`.

  Parameters:
    `mimeType` - the mime-type of the file to be created. This parameter may be used to inform the BlobStore of the mime-type for the file. The mime-type will be returned by the BlobStore in an HTTP response if the file is requested directly from the BlobStore using the blob-key.
    `blobInfoUploadedFileName` - BlobStore will store this name in the BlobInfo's fileName field. This string will not be the `name` of the returned `AppEngineFile`. It will be returned by the BlobStore in an HTTP response if the file is requested directly from the BlobStore using the blob-key.
  Returns:
    A `AppEngineFile` representing the newly created file.
  Throws:
    `java.io.IOException` - If there is any problem communicating with the backend system

### openWriteChannel

    FileWriteChannel openWriteChannel(AppEngineFile file,
                                      boolean lock)
                                      throws java.io.FileNotFoundException,
                                             FinalizationException,
                                             LockException,
                                             java.io.IOException

  Given an `AppEngineFile`, returns a `FileWriteChannel` that may be used for appending bytes to the file.

  Parameters:
    `file` - the file to which to append bytes. The file must exist and it must not yet have been finalized.
    `lock` - should the file be locked for exclusive access?
  Throws:
    `java.io.FileNotFoundException` - if the file does not exist in the backend repository. The file may have been deleted by another request, or the file may have been lost due to system failure or a scheduled relocation. Each backend repository offers different guarantees regarding when this is possible.
    `FinalizationException` - if the file has already been finalized. The file may have been finalized by another request.
    `LockException` - if the file is locked in a different App Engine request, or if `lock = true` and the file is opened in a different App Engine request
    `java.io.IOException` - if any other unexpected problem occurs

### openReadChannel

    FileReadChannel openReadChannel(AppEngineFile file,
                                    boolean lock)
                                    throws java.io.FileNotFoundException,
                                           LockException,
                                           java.io.IOException

  Given an `AppEngineFile`, returns a `FileReadChannel` that may be used for reading bytes from the file.

  Parameters:
    `file` - The file from which to read bytes. The file must exist and it must have been finalized.
    `lock` - Should the file be locked for exclusive access?
  Throws:
    `java.io.FileNotFoundException` - if the file does not exist in the backend repository. The file may have been deleted by another request, or the file may have been lost due to system failure or a scheduled relocation. Each backend repository offers different guarantees regarding when this is possible.
    `FinalizationException` - if the file has not yet been finalized
    `LockException` - if the file is locked in a different App Engine request, or if `lock = true` and the file is opened in a different App Engine request
    `java.io.IOException` - if any other problem occurs contacting the backend system

### getBlobKey

    BlobKey getBlobKey(AppEngineFile file)

  Given a `BLOBSTORE` file that has been finalized, returns the `BlobKey` for the corresponding blob.

  Parameters:
    `file` - A `BLOBSTORE` file that has been finalized
  Returns:
    The corresponding `BlobKey`, or `null` if none can be found. This can occur if the file has not been finalized, or if it does not exist.
  Throws:
    `java.lang.IllegalArgumentException` - if `file` is not a `BLOBSTORE` file.

### getBlobFile

    AppEngineFile getBlobFile(BlobKey blobKey)
                              throws java.io.FileNotFoundException

  Given a `BlobKey` returns the corresponding `AppEngineFile`. The file has been finalized.

  Parameters:
    `blobKey` - A blobkey
  Returns:
    The corresponding file.
  Throws:
    `java.io.FileNotFoundException` - if there is no blob with the given blob key.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD