Converts a Native File Object to Upload File object
9133
protected UploadFile convertUploadFile(File file) {
        Date lastModifiedDate = new Date();
        // Avoid parsing error on last modified date
        if (file.lastModifiedDate != null && !file.lastModifiedDate.isEmpty()) {
            lastModifiedDate = new Date(file.lastModifiedDate);
        }
        return new UploadFile(file.name, lastModifiedDate, Double.parseDouble(file.size), file.type);
    }
1100305
def __upload(self, resource, bytes):
        """"""

        # note: string conversion required here due to open encoding bug in requests-oauthlib.
        headers = {
            'x-ton-expires': http_time(self.options.get('x-ton-expires', self._DEFAULT_EXPIRE)),
            'content-length': str(self._file_size),
            'content-type': self.content_type
        }

        return Request(self._client, 'post', resource,
                       domain=self._DEFAULT_DOMAIN, headers=headers, body=bytes).perform()
185923
def upload(config, remote_loc, u_filename):
    """"""
    rcode = False
    try:
        sftp, transport = get_sftp_conn(config)
        remote_dir = get_remote_path(remote_loc)
        for part in ['sha1', 'asc']:
            local_file = '%s.%s' % (u_filename, part)
            remote_file = os.path.join(remote_dir, local_file)
            sftp.put(local_file, remote_file)
        sftp.put(remote_dir, os.path.join(remote_dir, u_filename))
        rcode = True
    except BaseException:
        pass
    finally:
        if 'transport' in locals():
            transport.close()
    return rcode
836036
def upload_path(instance, filename):
    '''
        
    '''

    filename = filename.replace(" ", "_")
    filename = unicodedata.normalize('NFKD', filename).lower()
    return os.path.join(str(timezone.now().date().isoformat()), filename)
489787
private <RequestT, ResponseT> ResponseT uploadObject(final InputStream originalStream,
                                                         final File file,
                                                         final ObjectMetadata metadata,
                                                         final ProgressListener listener,
                                                         final Request<RequestT> request,
                                                         final S3DataSource originalRequest,
                                                         final boolean skipServerSideValidation,
                                                         final boolean skipClientSideValidationPerRequest,
                                                         final UploadObjectStrategy<RequestT, ResponseT> uploadStrategy,
                                                         final boolean setContentTypeIfNotProvided) {

        InputStream input = getInputStream(originalStream, file, metadata, request,
                                           skipServerSideValidation, setContentTypeIfNotProvided);

        final ObjectMetadata returnedMetadata;
        MD5DigestCalculatingInputStream md5DigestStream = null;
        try {
            if (metadata.getContentMD5() == null && !skipClientSideValidationPerRequest) {
                /*
                 * If the user hasn't set the content MD5, then we don't want to buffer the whole
                 * stream in memory just to calculate it. Instead, we can calculate it on the fly
                 * and validate it with the returned ETag from the object upload.
                 */
                input = md5DigestStream = new MD5DigestCalculatingInputStream(input);
            }

            populateRequestMetadata(request, metadata);
            request.setContent(input);
            publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
            try {
                returnedMetadata = uploadStrategy.invokeServiceCall(request);
            } catch (Throwable t) {
                publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
                throw failure(t);
            }
        } finally {
            cleanupDataSource(originalRequest, file, originalStream, input, log);
        }

        String contentMd5 = metadata.getContentMD5();
        if (md5DigestStream != null) {
            contentMd5 = Base64.encodeAsString(md5DigestStream.getMd5Digest());
        }

        final String etag = returnedMetadata.getETag();
        if (contentMd5 != null && !skipMd5CheckStrategy.skipClientSideValidationPerPutResponse(returnedMetadata)) {
            byte[] clientSideHash = BinaryUtils.fromBase64(contentMd5);
            byte[] serverSideHash = BinaryUtils.fromHex(etag);

            if (!Arrays.equals(clientSideHash, serverSideHash)) {
                publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
                throw new SdkClientException(
                    "Unable to verify integrity of data upload. Client calculated content hash (contentMD5: " + contentMd5
                    + " in base 64) didn't match hash (etag: " + etag + " in hex) calculated by Amazon S3.  "
                    + "You may need to delete the data stored in Amazon S3. (metadata.contentMD5: " + metadata.getContentMD5()
                    + ", md5DigestStream: " + md5DigestStream
                    + uploadStrategy.md5ValidationErrorSuffix()
                    + ")");
            }
        }

        publishProgress(listener, ProgressEventType.TRANSFER_COMPLETED_EVENT);

        return uploadStrategy.createResult(returnedMetadata, contentMd5);
    }
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);
    }
  }
565314
def _fileobj_to_fd(fileobj):
    
    if isinstance(fileobj, _INTEGER_TYPES):
        fd = fileobj
    else:
        for _integer_type in _INTEGER_TYPES:
            try:
                fd = _integer_type(fileobj.fileno())
                break
            except (AttributeError, TypeError, ValueError):
                continue
        else:
            raise ValueError("Invalid file object: {0!r}".format(fileobj))
    if fd < 0:
        raise ValueError("Invalid file descriptor: {0}".format(fd))
    return fd
900260
def Upload(cls, filename):
        
        raise Exception("to do")
    
        TOOLS_PATH = ""
        RESOURCE_PATH = ""
        tool_4path = os.path.join(TOOLS_PATH, "upload.exe")        
        file_4path = os.path.join(RESOURCE_PATH, filename)
        #file_4path.decode('utf-8').encode('gbk')
        
        if os.path.isfile(file_4path):
            cls.Click()
            os.system(tool_4path + ' ' + file_4path)
        else:
            raise Exception('%s is not exists' % file_4path)
795943
def to_native(self, obj, name, value):  # pylint:disable=unused-argument
		""""""
		
		if self.mapping:
			for original, new in self.mapping.items():
				value = value.replace(original, new)
		
		return load(value, self.namespace)
858868
function uploadContent(client) {
  const content = document.getElementById('file-content').value.trim();
  const key = document.getElementById('object-key-content').value.trim() || 'object';
  console.log(`content => ${key}`);

  return client.put(key, new Buffer(content)).then(res => listFiles(client));
}
446597
def upload_path(instance, filename):
    '''
    
    '''
    path_separator = "/"
    date_separator = "-"
    ext_separator = "."
    empty_string = ""
    # get the model name
    model_name = model_inspect(instance)['modelname']

    # get the string date
    date = datetime.now().strftime("%Y-%m-%d").split(date_separator)
    curr_day = date[2]
    curr_month = date[1]
    curr_year = date[0]

    split_filename = filename.split(ext_separator)
    filename = empty_string.join(split_filename[:-1])
    file_ext = split_filename[-1]

    new_filename = empty_string.join([filename, str(random.random()).split(ext_separator)[1]])
    new_filename = ext_separator.join([new_filename, file_ext])
    string_path = path_separator.join([model_name, curr_year, curr_month, curr_day, new_filename])
    # the path is built using the current date and the modelname
    return string_path
1111707
def upload_to(instance, filename, prefix=None):
    
    ext = path.splitext(filename)[1]
    name = str(instance.pk or time()) + filename

    # We think that we use utf8 based OS file system
    filename = md5(name.encode('utf8')).hexdigest() + ext
    basedir = path.join(instance._meta.app_label, instance._meta.module_name)
    if prefix:
        basedir = path.join(basedir, prefix)
    return path.join(basedir, filename[:2], filename[2:4], filename)
476143
function upload (options, callback) {
  const promise = (
    Promise.resolve(options)
      .then(applyDefaults)
      .then(validateOptions)
      .then(opts => {
        options = opts
        return options
      })
      .then(transformOptions)
      .then(prepareRequest)
      .then(sendRequest)
      .catch(err => {
        return cleanupTempFiles(options)
          .then(() => Promise.reject(err))
      })
      .then(cleanupTempFiles)
  )
  if (callback) {
    promise
      .then(message => callback(null, message))
      .catch(err => callback(err, null))
  }
  return promise
}
1219984
async function convert(filename, options) {
    let file;
    if (filename) {
        file = fs.readFileSync(filename).toString();
    } else {
        file = await read_stdin();
    }
    try {
        file = JSON.parse(file);
    } catch {}
    let tbl = table(file);
    let view = tbl.view();
    let out;
    options.format = options.format || "arrow";
    if (options.format === "csv") {
        out = await view.to_csv();
    } else if (options.format === "columns") {
        out = JSON.stringify(await view.to_columns());
    } else if (options.format === "json") {
        out = JSON.stringify(await view.to_json());
    } else {
        out = await view.to_arrow();
    }
    if (options.format === "arrow") {
        if (options.output) {
            fs.writeFileSync(options.output, new Buffer(out), "binary");
        } else {
            console.log(new Buffer(out).toString());
        }
    } else {
        if (options.output) {
            fs.writeFileSync(options.output, out);
        } else {
            console.log(out);
        }
    }
    view.delete();
    tbl.delete();
}
1154855
def file_upload_to(self, instance, filename):
        
        ext = filename.split(".")[-1]
        filename = "{}.{}".format(uuid.uuid4(), ext)
        return os.path.join("document", filename)
1240859
public static File toFile(Object obj) throws PageException {
	if (obj instanceof File) return (File) obj;
	return FileUtil.toFile(Caster.toString(obj));
    }
549944
private Object convertFile(Object name) throws IOException, JSONException{
    if (name instanceof String) {
      String file = (String) name;
      JSONObject json = getJsonConfig(file);
      if (json!=null) {
        return json;
      }
    } else if (name instanceof Path) {
        Path file = (Path)name;
        JSONObject json = getJsonConfig(file);
        if (json != null) {
          return json;
        }
    } 
    return name;
  }