Method to upload the file for the given entity in asynchronous fashion

@param entity
the entity
@param docContent
the content of the file to upload
@param callbackHandler
the callback handler
@throws FMSException
throws FMSException
18566
public <T extends IEntity> void uploadAsync(T entity, InputStream docContent, CallbackHandler callbackHandler) throws FMSException {

        IntuitMessage intuitMessage = prepareUpload(entity, docContent);

        //set callback handler
        intuitMessage.getRequestElements().setCallbackHandler(callbackHandler);

        //execute async interceptors
        executeAsyncInterceptors(intuitMessage);
    }
246781
Document createDocument(Entity entity) {
    int maxIndexingDepth = entity.getEntityType().getIndexingDepth();
    XContentBuilder contentBuilder;
    try {
      contentBuilder = XContentFactory.contentBuilder(JSON);
      XContentGenerator generator = contentBuilder.generator();
      generator.writeStartObject();
      createRec(entity, generator, 0, maxIndexingDepth);
      generator.writeEndObject();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    String documentId = toElasticsearchId(entity.getIdValue());
    return Document.create(documentId, contentBuilder);
  }
507762
private ListenerToken addDocumentChangeListener(
        Executor executor,
        DocumentChangeListener listener,
        String docID) {
        // NOTE: caller method is synchronized.
        DocumentChangeNotifier docNotifier = docChangeNotifiers.get(docID);
        if (docNotifier == null) {
            docNotifier = new DocumentChangeNotifier((Database) this, docID);
            docChangeNotifiers.put(docID, docNotifier);
        }
        final ChangeListenerToken token = docNotifier.addChangeListener(executor, listener);
        token.setKey(docID);
        return token;
    }
151057
def sendIq(self, entity):
        
        if entity.getType() == IqProtocolEntity.TYPE_SET and entity.getXmlns() == "w:m":
            #media upload!
            self._sendIq(entity, self.onRequestUploadSuccess, self.onRequestUploadError)
1048454
async def send_document(self, path, entity):
        """"""
        await self.send_file(
            entity, path,
            force_document=True,
            progress_callback=self.upload_progress_callback
        )
        print('Document sent!')
873525
public <T extends IEntity> void voidRequestAsync(T entity, CallbackHandler callbackHandler) throws FMSException {

        IntuitMessage intuitMessage = prepareVoidRequest(entity);

        //set callback handler
        intuitMessage.getRequestElements().setCallbackHandler(callbackHandler);

        //execute async interceptors
        executeAsyncInterceptors(intuitMessage);
    }
21911
@Override
  public synchronized void upload(File fileToUpload, String filename,
      String contents, String comment) throws Exception {
    this.upload(new FileInputStream(fileToUpload), filename, contents, comment);
  }
272744
public void writeData(Object entity, EntityType entityType) throws XMLStreamException, ODataRenderException {

        xmlWriter.writeStartElement(ODATA_CONTENT);
        xmlWriter.writeAttribute(TYPE, XML.toString());
        xmlWriter.writeStartElement(METADATA, ODATA_PROPERTIES, "");

        marshall(entity, entityType);

        xmlWriter.writeEndElement();
        xmlWriter.writeEndElement();
    }
212021
@Override
    public synchronized void insertUpdate(DocumentEvent e) {
        int len = e.getLength();
        int off = e.getOffset();
        if (outputMark > off) {
            outputMark += len;
        }
    }
1071771
public void executeEntityListeners(CallbackType callbackType, List<?> entities) {
    for (Object entity : entities) {
      executeEntityListeners(callbackType, entity);
    }
  }
103321
public void setContent(final byte[] content,
                         final String contentType) throws HttpException {
    if (!(method instanceof HttpEntityEnclosingRequestBase)) {
      throw new HttpException("Invalid operation for method " +
                               method.getMethod());
    }

    final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase)method;

    ByteArrayEntity entity = new ByteArrayEntity(content);
    entity.setContentType(contentType);
    eem.setEntity(entity);
  }
1106938
@Transactional
  @PostMapping(value = "/{entityTypeId}", headers = "Content-Type=multipart/form-data")
  public void createFromFormPostMultiPart(
      @PathVariable("entityTypeId") String entityTypeId,
      MultipartHttpServletRequest request,
      HttpServletResponse response) {
    Map<String, Object> paramMap = new HashMap<>();
    for (String param : request.getParameterMap().keySet()) {
      String[] values = request.getParameterValues(param);
      String value = values != null ? StringUtils.join(values, ',') : null;
      if (StringUtils.isNotBlank(value)) {
        paramMap.put(param, value);
      }
    }

    // add files to param map
    for (Entry<String, List<MultipartFile>> entry : request.getMultiFileMap().entrySet()) {
      String param = entry.getKey();
      List<MultipartFile> files = entry.getValue();
      if (files != null && files.size() > 1) {
        throw new IllegalArgumentException("Multiple file input not supported");
      }
      paramMap.put(param, files != null && !files.isEmpty() ? files.get(0) : null);
    }
    createInternal(entityTypeId, paramMap, response);
  }
612962
public VoiceFileUploaderResult upload(byte[] fileContent, ContentType contentType)
            throws HTTPException, JSONException, IOException {

        long random = SmsSenderUtil.getRandom();
        long now = SmsSenderUtil.getCurrentTime();
        String fileSha1Sum = SmsSenderUtil.sha1sum(fileContent);
        String auth = SmsSenderUtil.calculateAuth(this.appkey, random, now, fileSha1Sum);
        String type;
        if (contentType == ContentType.WAV) {
            type = "audio/wav";
        } else {
            type = "audio/mpeg";
        }

        HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url)
            .addHeader("Content-Type", type)
            .addHeader("x-content-sha1", fileSha1Sum)
            .addHeader("Authorization", auth)
            .addQueryParameter("sdkappid", this.appid)
            .addQueryParameter("random", random)
            .addQueryParameter("time", now)
            .setConnectionTimeout(60 * 1000)
            .setRequestTimeout(60 * 1000)
            .setBody(new String(fileContent, StandardCharsets.ISO_8859_1))
            .setBodyCharset(StandardCharsets.ISO_8859_1);

        try {
            // May throw IOException and URISyntaxexception
            HTTPResponse res = httpclient.fetch(req);

            // May throw HTTPException
            handleError(res);

            // May throw JSONException
            return (new VoiceFileUploaderResult()).parseFromHTTPResponse(res);
        } catch(URISyntaxException e) {
            throw new RuntimeException("API url has been modified, current url: " + url);
        }
    }
1189186
function uploadHandler (event) {
    const target = event.target;

    if (target.files && target.files[0]) {
      file = target.files[0];
      const reader = new FileReader();

      reader.addEventListener('load', loadHandler);

      reader.readAsDataURL(file);
    }
  }
506011
public void upload(final String uri, final File sourceFile, final String contentType)
            throws IOException, AppPlatformException {
        final String path = getPath(uri);
        final HttpPut request = (HttpPut) setupRequest(path, HttpPut.METHOD_NAME, null);
        request.setEntity(contentType == null ? new FileEntity(sourceFile) : new FileEntity(sourceFile, ContentType.parse(contentType)));
        performRequest(request);
    }
642545
public function updateRecord($documentId, $entity, $returnEntity = true)
    {
        if (!is_null($documentId)) {
            $this->deleteById($documentId);
            // detach so odm knows it's gone
            $this->manager->detach($entity);
            $this->manager->clear();
        }

        $entity = $this->manager->merge($entity);

        $this->manager->persist($entity);
        $this->manager->flush($entity);
        $this->manager->detach($entity);

        // Fire ModelEvent
        $this->dispatchModelEvent(ModelEvent::MODEL_EVENT_UPDATE, $entity);

        if ($returnEntity) {
            return $entity;
        }
        return null;
    }
991475
@SuppressWarnings("unchecked")
    public <T extends IEntity> T update(T entity) throws FMSException {

        IntuitMessage intuitMessage = prepareUpdate(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        return (T) retrieveEntity(intuitMessage);
    }