Search in sources :

Example 1 with StreamUploaderSingleCall

use of com.github.davidmoten.odata.client.StreamUploaderSingleCall in project odata-client by davidmoten.

the class RequestHelper method uploader.

public static Optional<StreamUploaderSingleCall> uploader(ContextPath contextPath, ODataType item, String fieldName, HttpMethod method) {
    Preconditions.checkNotNull(fieldName);
    String editLink = (String) item.getUnmappedFields().get(fieldName + "@odata.mediaEditLink");
    String contentType = (String) item.getUnmappedFields().get(fieldName + "@odata.mediaContentType");
    if (editLink == null) {
        return Optional.empty();
    } else {
        // TODO support relative editLink?
        Context context = contextPath.context();
        if (contentType == null) {
            contentType = CONTENT_TYPE_APPLICATION_OCTET_STREAM;
        }
        Path path = new Path(editLink, contextPath.path().style());
        return Optional.of(new StreamUploaderSingleCall(new ContextPath(context, path), contentType, method));
    }
}
Also used : Context(com.github.davidmoten.odata.client.Context) ContextPath(com.github.davidmoten.odata.client.ContextPath) Path(com.github.davidmoten.odata.client.Path) ContextPath(com.github.davidmoten.odata.client.ContextPath) StreamUploaderSingleCall(com.github.davidmoten.odata.client.StreamUploaderSingleCall)

Aggregations

Context (com.github.davidmoten.odata.client.Context)1 ContextPath (com.github.davidmoten.odata.client.ContextPath)1 Path (com.github.davidmoten.odata.client.Path)1 StreamUploaderSingleCall (com.github.davidmoten.odata.client.StreamUploaderSingleCall)1