Package com.contentful.java.cma
Class ModuleUploads
- java.lang.Object
-
- com.contentful.java.cma.ModuleUploads
-
public class ModuleUploads extends java.lang.ObjectUpload Module.This module will take care of all `upload.contentful.com` related issues, as in directly uploading a file to Contentful, receiving its id.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classModuleUploads.AsyncAsync module.
-
Constructor Summary
Constructors Constructor Description ModuleUploads(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create uploads module.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModuleUploads.Asyncasync()CMAUploadcreate(java.io.InputStream stream)Create a new upload on the configured space.CMAUploadcreate(java.io.InputStream stream, int chunkSize)CMAUploadcreate(java.lang.String spaceId, java.lang.String environmentId, java.io.InputStream stream)CMAUploadcreate(java.lang.String spaceId, java.lang.String environmentId, java.io.InputStream stream, int chunkSize)Create a new upload.protected com.contentful.java.cma.ServiceUploadscreateService(retrofit2.Retrofit retrofit)intdelete(CMAUpload upload, java.lang.String environmentId)Delete a given upload again.CMAUploadfetchOne(java.lang.String uploadId, java.lang.String environmentId)Get information about a given upload on the configured space.CMAUploadfetchOne(java.lang.String spaceId, java.lang.String environmentId, java.lang.String uploadId)Get information about the given upload.
-
-
-
Constructor Detail
-
ModuleUploads
public ModuleUploads(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create uploads module.- Parameters:
retrofit- the retrofit instance to be used to create the service.callbackExecutor- to tell on which thread it should run.spaceId- the space to be used when not given.environmentId- the environment to be used when not given.environmentIdConfigured- internal helper to see if environment was set.
-
-
Method Detail
-
createService
protected com.contentful.java.cma.ServiceUploads createService(retrofit2.Retrofit retrofit)
-
create
public CMAUpload create(java.io.InputStream stream) throws java.io.IOException
Create a new upload on the configured space.Once an upload is created, you can use it in
ModuleAssetsthroughCMAClient.assets()for creating an asset based on a local file.- Parameters:
stream- the actual binary representation of the upload. Cannot be null.- Returns:
- the upload created, containing the id to be used further on.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if stream is null.java.io.IOException- if the stream could not be read.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
create
public CMAUpload create(java.io.InputStream stream, int chunkSize) throws java.io.IOException
- Throws:
java.io.IOException
-
create
public CMAUpload create(java.lang.String spaceId, java.lang.String environmentId, java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
create
public CMAUpload create(java.lang.String spaceId, java.lang.String environmentId, java.io.InputStream stream, int chunkSize) throws java.io.IOException
Create a new upload.Once an upload is created, you can use it in
ModuleAssetsthroughCMAClient.assets()for creating an asset based on a local file.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)and will ignoreCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- a nonnull id representing the space to add the upload to.stream- the actual binary representation of the upload. Cannot be null.- Returns:
- the upload created, containing the id to be used further on.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if stream is null.java.io.IOException- if the stream could not be read.
-
fetchOne
public CMAUpload fetchOne(java.lang.String uploadId, java.lang.String environmentId)
Get information about a given upload on the configured space.- Parameters:
uploadId- what id does the upload have?- Returns:
- an CMAUpload based on this id and space combination.
- Throws:
java.lang.IllegalArgumentException- if configured spaceId is null.java.lang.IllegalArgumentException- if uploadId is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
fetchOne
public CMAUpload fetchOne(java.lang.String spaceId, java.lang.String environmentId, java.lang.String uploadId)
Get information about the given upload.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)and will ignoreCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- which space is this upload hosted under?uploadId- what id does the upload have?- Returns:
- an CMAUpload based on this id and space combination.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if uploadId is null.
-
delete
public int delete(CMAUpload upload, java.lang.String environmentId)
Delete a given upload again.- Parameters:
upload- upload- Returns:
- response code, 204 on success.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if uploadId is null.
-
async
public ModuleUploads.Async async()
- Returns:
- a module with a set of asynchronous methods.
-
-