Upload setting.

@param req the req
199079
@PostMapping("/setting/upload/json")
    public void uploadSetting(HttpServletRequest req) {
        this.validationSessionComponent.sessionCheck(req);
        this.msgSettingService.updateValidationData((MultipartHttpServletRequest) req);
    }
377447
@Override
  public void service(RequestWeb req)
  {
    init();
    
    String pathInfo = req.pathInfo();
    
    if (pathInfo.isEmpty() || pathInfo.equals("/")) {
      pathInfo = _config.get("server.index", "index.html");
    } else {
      pathInfo = pathInfo.substring(1);
    }

    Path path = _root.resolve(pathInfo);
    //PathImpl path = Vfs.lookup(root).lookup("./" + pathInfo);
    
    if (Files.isDirectory(path)) {
      path = path.resolve(_config.get("server.index", "index.html"));
    }
    
    long len;
    
    try {
      len = Files.size(path);
    } catch (IOException e) {
      
      req.fail(new FileNotFoundException("file not found: " + req.uri()));
      return;
    }
    
    try (InputStream is = Files.newInputStream(path)) {
      if (is == null) {
        req.fail(new FileNotFoundException(pathInfo));
        return;
      }

      String mimeType = mimeType(pathInfo);
      
      if (mimeType != null) {
        req.header("content-type", mimeType);
      }
      else {
        req.header("content-type", "text/plain; charset=utf-8");
      }
      
      // XXX:
      if (len > 0) {
        req.length(len);
      }
      
      TempBuffer tBuf = TempBuffer.create();
      byte []buffer = tBuf.buffer();
      
      int sublen;
      
      while ((sublen = is.read(buffer, 0, buffer.length)) > 0) {
        req.write(buffer, 0, sublen);
      }
      
      tBuf.free();
    } catch (IOException e) {
      req.fail(e);
    }
    
    req.ok();
  }
889034
void processFormSubmitRequest(HttpServletRequest request) {

        String formDataId = getFormDataId(request);
        List<FileItem> items = CmsRequestUtil.readMultipartFileItems(request);
        m_storedFormData.put(formDataId, items);
    }
508047
public void addRequest(RecordRequest request) {
        if (request.getRequestSize() + getRequestSize() > 248) {
            throw new IllegalArgumentException();
        }

        if (records == null) {
            records = new RecordRequest[1];
        }
        else {
            RecordRequest old[] = records;
            records = new RecordRequest[old.length + 1];

            System.arraycopy(old, 0, records, 0, old.length);
        }
        records[records.length - 1] = request;

        setDataLength(getRequestSize());
    }
1081503
public String onUploadInitiation(UploadObjectRequest req) {
        InitiateMultipartUploadResult res =
            s3.initiateMultipartUpload(newInitiateMultipartUploadRequest(req));
        return this.uploadId = res.getUploadId();
    }
199816
public void setRequest(ModbusRequest req) {
        request = req;
        if (req != null) {
            request.setTransactionID(getTransactionID());
        }
    }
364770
public void upload(Map<String, ParameterBindingDTO> bindValues) throws BindException
  {
    if (!closed)
    {
      serializeBinds(bindValues);
      putBinds();
    }
  }
107308
private void setup() {
        try {
            this.partBoundary = ("--" + boundary).getBytes("UTF-8");
            this.trailingBoundary = ("--" + boundary + "--").getBytes("UTF-8");
            this.contentType = "content-type: application/json".getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }

        attachments = new ArrayList<Attachment>();

        // some preamble
        contentLength += partBoundary.length;
        contentLength += 6; // 3 * crlf
        contentLength += contentType.length;

        // although we haven't added it yet, account for the trailing boundary
        contentLength += 2; // crlf
        contentLength += trailingBoundary.length;
    }
418061
def InitializeUpload(self, http_request, http=None, client=None):
        """"""
        if self.strategy is None:
            raise exceptions.UserError(
                'No upload strategy set; did you call ConfigureRequest?')
        if http is None and client is None:
            raise exceptions.UserError('Must provide client or http.')
        if self.strategy != RESUMABLE_UPLOAD:
            return
        http = http or client.http
        if client is not None:
            http_request.url = client.FinalizeTransferUrl(http_request.url)
        self.EnsureUninitialized()
        http_response = http_wrapper.MakeRequest(http, http_request,
                                                 retries=self.num_retries)
        if http_response.status_code != http_client.OK:
            raise exceptions.HttpError.FromResponse(http_response)

        self.__server_chunk_granularity = http_response.info.get(
            'X-Goog-Upload-Chunk-Granularity')
        url = http_response.info['location']
        if client is not None:
            url = client.FinalizeTransferUrl(url)
        self._Initialize(http, url)

        # Unless the user has requested otherwise, we want to just
        # go ahead and pump the bytes now.
        if self.auto_transfer:
            return self.StreamInChunks()
        return http_response
877808
public void setUploadMetadata(com.google.api.ads.adwords.axis.v201809.rm.UploadMetadata uploadMetadata) {
        this.uploadMetadata = uploadMetadata;
    }
875084
def upload(self):
        ''''''
        info = pcs.upload(self.cookie, self.row[SOURCEPATH_COL],
                          self.row[PATH_COL], self.upload_mode)
        if info:
            self.emit('uploaded', self.row[FID_COL])
        else:
            self.emit('network-error', self.row[FID_COL])
426573
private void putLocalObject(final UploadObjectRequest reqIn,
            OutputStream os) throws IOException {
        UploadObjectRequest req = reqIn.clone();

        final File fileOrig = req.getFile();
        final InputStream isOrig = req.getInputStream();

        if (isOrig == null) {
            if (fileOrig == null)
                throw new IllegalArgumentException("Either a file lor input stream must be specified");
            req.setInputStream(new FileInputStream(fileOrig));
            req.setFile(null);
        }

        try {
            IOUtils.copy(req.getInputStream(), os);
        } finally {
            cleanupDataSource(req, fileOrig, isOrig,
                    req.getInputStream(), log);
            IOUtils.closeQuietly(os, log);
        }
        return;
    }
381692
def set_uploading(self, files_uploaded):
        
        self.files_uploaded = files_uploaded
        self.__record_progress(Status.UPLOADING_FILES)
803701
def ConfigureRequest(self, upload_config, http_request, url_builder):
        """"""
        # Validate total_size vs. max_size
        if (self.total_size and upload_config.max_size and
                self.total_size > upload_config.max_size):
            raise exceptions.InvalidUserInputError(
                'Upload too big: %s larger than max size %s' % (
                    self.total_size, upload_config.max_size))
        # Validate mime type
        if not util.AcceptableMimeType(upload_config.accept, self.mime_type):
            raise exceptions.InvalidUserInputError(
                'MIME type %s does not match any accepted MIME ranges %s' % (
                    self.mime_type, upload_config.accept))

        self.__SetDefaultUploadStrategy(upload_config, http_request)
        if self.strategy == SIMPLE_UPLOAD:
            url_builder.relative_path = upload_config.simple_path
            if http_request.body:
                url_builder.query_params['uploadType'] = 'multipart'
                self.__ConfigureMultipartRequest(http_request)
            else:
                url_builder.query_params['uploadType'] = 'media'
                self.__ConfigureMediaRequest(http_request)
            # Once the entire body is written, compress the body if configured
            # to. Both multipart and media request uploads will read the
            # entire stream into memory, which means full compression is also
            # safe to perform. Because the strategy is set to SIMPLE_UPLOAD,
            # StreamInChunks throws an exception, meaning double compression
            # cannot happen.
            if self.__gzip_encoded:
                http_request.headers['Content-Encoding'] = 'gzip'
                # Turn the body into a stream so that we can compress it, then
                # read the compressed bytes.  In the event of a retry (e.g. if
                # our access token has expired), we need to be able to re-read
                # the body, which we can't do with a stream. So, we consume the
                # bytes from the stream now and store them in a re-readable
                # bytes container.
                http_request.body = (
                    compression.CompressStream(
                        six.BytesIO(http_request.body))[0].read())
        else:
            url_builder.relative_path = upload_config.resumable_path
            url_builder.query_params['uploadType'] = 'resumable'
            self.__ConfigureResumableRequest(http_request)
680203
private static InputStream cap(final Request req) throws IOException {
        final Iterator<String> hdr = new RqHeaders.Base(req)
            .header("Content-Length").iterator();
        InputStream body = req.body();
        long length = (long) body.available();
        if (hdr.hasNext()) {
            length = Long.parseLong(hdr.next());
        }
        body = new CapInputStream(body, length);
        return body;
    }
457245
CompleteMultipartUploadResult uploadObject(final UploadObjectRequest req)
            throws IOException, InterruptedException, ExecutionException {
        // Set up the pipeline for concurrent encrypt and upload
        // Set up a thread pool for this pipeline
        ExecutorService es = req.getExecutorService();
        final boolean defaultExecutorService = es == null;
        if (es == null)
            es = Executors.newFixedThreadPool(clientConfiguration.getMaxConnections());
        UploadObjectObserver observer = req.getUploadObjectObserver();
        if (observer == null)
            observer = new UploadObjectObserver();
        // initialize the observer
        observer.init(req, this, this, es);
        // Initiate upload
        observer.onUploadInitiation(req);
        final List<PartETag> partETags = new ArrayList<PartETag>();
        MultiFileOutputStream mfos = req.getMultiFileOutputStream();
        if (mfos == null)
            mfos = new MultiFileOutputStream();
        try {
            // initialize the multi-file output stream
            mfos.init(observer, req.getPartSize(), req.getDiskLimit());
            // Kicks off the encryption-upload pipeline;
            // Note mfos is automatically closed upon method completion.
            putLocalObject(req, mfos);
            // block till all part have been uploaded
            for (Future<UploadPartResult> future: observer.getFutures()) {
                UploadPartResult partResult = future.get();
                partETags.add(new PartETag(partResult.getPartNumber(), partResult.getETag()));
            }
        } finally {
            if (defaultExecutorService)
                es.shutdownNow();   // shut down the locally created thread pool
            mfos.cleanup();       // delete left-over temp files
        }
        // Complete upload
        return observer.onCompletion(partETags);
    }
980109
private void execUpload(UploadPartRequest request) {
    File file = request.getFile();
    ListenableFuture<PartETag> futureTag =
        mExecutor.submit((Callable) () -> {
          PartETag partETag;
          AmazonClientException lastException;
          try {
            do {
              try {
                partETag = mClient.uploadPart(request).getPartETag();
                return partETag;
              } catch (AmazonClientException e) {
                lastException = e;
              }
            } while (mRetryPolicy.attempt());
          } finally {
            // Delete the uploaded or failed to upload file
            if (!file.delete()) {
              LOG.error("Failed to delete temporary file @ {}", file.getPath());
            }
          }
          throw new IOException("Fail to upload part " + request.getPartNumber()
              + " to " + request.getKey(), lastException);
        });
    mTagFutures.add(futureTag);
    LOG.debug("Submit upload part request. key={}, partNum={}, file={}, fileSize={}, lastPart={}.",
        mKey, request.getPartNumber(), file.getPath(), file.length(), request.isLastPart());
  }