Class StorageFileResource
java.lang.Object
org.springframework.core.io.AbstractResource
com.azure.spring.cloud.core.resource.StorageFileResource
- All Implemented Interfaces:
org.springframework.core.io.InputStreamSource,org.springframework.core.io.Resource,org.springframework.core.io.WritableResource
public final class StorageFileResource
extends org.springframework.core.io.AbstractResource
Implements
WritableResource for reading and writing objects in Azure StorageAccount file. An instance of this
class represents a handle to a file.-
Constructor Summary
ConstructorsConstructorDescriptionStorageFileResource(com.azure.storage.file.share.ShareServiceClient shareServiceClient, String location) Creates a new instance ofStorageFileResource.StorageFileResource(com.azure.storage.file.share.ShareServiceClient shareServiceClient, String location, boolean autoCreateFiles) Creates a new instance ofStorageFileResource.StorageFileResource(com.azure.storage.file.share.ShareServiceClient shareServiceClient, String location, boolean autoCreateFiles, String contentType) Creates a new instance ofStorageFileResource. -
Method Summary
Modifier and TypeMethodDescriptionlongorg.springframework.core.io.ResourcecreateRelative(String relativePath) Create relative resource from current location.booleanexists()Determines if the file this client represents exists in the cloud.getFile()This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.Checks whether an Azure Storage File can be opened, if the file is not existed, and autoCreateFiles==true, it will create the file on Azure Storage.getURL()Get the url of the storage file client.longMethods inherited from class org.springframework.core.io.AbstractResource
equals, getFileForLastModifiedCheck, getURI, hashCode, isFile, isOpen, isReadable, readableChannel, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.core.io.Resource
getContentAsByteArray, getContentAsString, getURI, isFile, isOpen, isReadable, readableChannelMethods inherited from interface org.springframework.core.io.WritableResource
isWritable, writableChannel
-
Constructor Details
-
Method Details
-
getOutputStream
Checks whether an Azure Storage File can be opened, if the file is not existed, and autoCreateFiles==true, it will create the file on Azure Storage.- Returns:
- A
StorageFileOutputStreamobject used to write data to the file. - Throws:
IOException- when fail to open the output stream.
-
exists
public boolean exists()Determines if the file this client represents exists in the cloud.- Specified by:
existsin interfaceorg.springframework.core.io.Resource- Overrides:
existsin classorg.springframework.core.io.AbstractResource- Returns:
- Flag indicating existence of the file.
-
getURL
Get the url of the storage file client.- Specified by:
getURLin interfaceorg.springframework.core.io.Resource- Overrides:
getURLin classorg.springframework.core.io.AbstractResource- Returns:
- the URL of the storage file client.
- Throws:
IOException
-
getFile
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.- Specified by:
getFilein interfaceorg.springframework.core.io.Resource- Overrides:
getFilein classorg.springframework.core.io.AbstractResource
-
contentLength
public long contentLength()- Specified by:
contentLengthin interfaceorg.springframework.core.io.Resource- Overrides:
contentLengthin classorg.springframework.core.io.AbstractResource- Returns:
- The number of bytes present in the response body.
-
lastModified
public long lastModified()- Specified by:
lastModifiedin interfaceorg.springframework.core.io.Resource- Overrides:
lastModifiedin classorg.springframework.core.io.AbstractResource- Returns:
- Last time the directory was modified.
-
createRelative
Create relative resource from current location.- Specified by:
createRelativein interfaceorg.springframework.core.io.Resource- Overrides:
createRelativein classorg.springframework.core.io.AbstractResource- Parameters:
relativePath- the relative path.- Returns:
- StorageFileResource with relative path from current location.
-
getFilename
- Specified by:
getFilenamein interfaceorg.springframework.core.io.Resource- Overrides:
getFilenamein classorg.springframework.core.io.AbstractResource- Returns:
- The name of the file.
-
getDescription
- Returns:
- a description for this resource, to be used for error output when working with the resource.
-
getInputStream
- Throws:
IOException
-