• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
BBFileRequestBody Class Reference

This class provides support for uploading files in Blackberry Dynamics Secure Storage together with BBCustomInterceptor. More...

Inherits RequestBody.

Description

// Create Multipart-body with a file in Secure Storage.
com.good.gd.file.File file = getFileInContatiner();
MultipartBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(),
BBFileRequestBody.create(file1, MediaType.get("text/plain")))
.build();
BBCustomInterceptor bbCustomInterceptor = new BBCustomInterceptor();
OkHttpClient httpClient = new OkHttpClient().newBuilder()
.addInterceptor(bbCustomInterceptor)
.authenticator(myAuthenticator) // optional Authenticator
.build();
// if Authenticator support is required
bbCustomInterceptor.initAuthenticatorSupport(httpClient);
val request = Request.Builder()
.url(urlStr)
.post(requestBody)
.build()
try (Response response = httpClient.newCall(request).execute()) {
return response.body().string();
}

Static Public Member Functions

static final RequestBody create (@NotNull com.good.gd.file.File file, @Nullable okhttp3.MediaType contentType)
 Returns a new request body that transmits the content of file. More...
 

Member Function Documentation

◆ create()

static final RequestBody create ( @NotNull com.good.gd.file.File  file,
@Nullable okhttp3.MediaType  contentType 
)
static
Parameters
fileFile in Secure Storage.
contentTypeMedia type of file content.