本文整理汇总了Java中com.dropbox.core.DbxWriteMode类的典型用法代码示例。如果您正苦于以下问题:Java DbxWriteMode类的具体用法?Java DbxWriteMode怎么用?Java DbxWriteMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DbxWriteMode类属于com.dropbox.core包,在下文中一共展示了DbxWriteMode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putSingleFile
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
private DbxEntry.File putSingleFile(File inputFile, String dropboxPath, DropboxUploadMode mode) throws Exception {
FileInputStream inputStream = new FileInputStream(inputFile);
DbxEntry.File uploadedFile = null;
try {
DbxWriteMode uploadMode = null;
if (mode == DropboxUploadMode.force) {
uploadMode = DbxWriteMode.force();
} else {
uploadMode = DbxWriteMode.add();
}
uploadedFile =
DropboxAPIFacade.client.uploadFile(dropboxPath,
uploadMode, inputFile.length(), inputStream);
return uploadedFile;
} finally {
inputStream.close();
}
}
示例2: upload
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public String upload(File fileToUpload) throws UploadException {
DbxRequestConfig dconfig = new DbxRequestConfig("sc-java", Locale
.getDefault().toString());
DbxClient client = new DbxClient(dconfig, config.getDropboxConfig()
.getAccessToken());
DbxEntry.File uploadedFile = null;
String shareLink = null;
try (InputStream inputStream = new FileInputStream(fileToUpload);) {
uploadedFile = client.uploadFile("/" + fileToUpload.getName(),
DbxWriteMode.add(), fileToUpload.length(), inputStream);
shareLink = client.createShareableUrl(uploadedFile.path);
} catch (DbxException | IOException e) {
throw new UploadException(e);
}
return shareLink;
}
示例3: subirArchivo
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
/**
* Permite subir el fichero de log a una cuenta de Dropbox
* @throws DbxException
* @throws IOException
*/
public void subirArchivo() throws DbxException, IOException{
DbxRequestConfig config = new DbxRequestConfig(
"JavaTutorial/1.0", Locale.getDefault().toString());
String accessToken = "cGF10uurG7MAAAAAAAAFGGi0UJD9H-TpMKBgESMHV5kDy5jTeF7ou8It1HY8ZFC7";
DbxClient client = new DbxClient(config, accessToken);
System.out.println("Linked account: " + client.getAccountInfo().displayName);
FileInputStream inputStream = new FileInputStream(archivoLog);
try {
DbxEntry.File uploadedFile = client.uploadFile(
"/ArchivoLog_ " + TheHouseOfCrimes.getUsuario() + "_" + TheHouseOfCrimes.getFecha(),
DbxWriteMode.add(), archivoLog.length(), inputStream);
System.out.println("Uploaded: " + uploadedFile.toString());
} finally {
inputStream.close();
}
}
示例4: call
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
protected final void call(final DbxClient client, final ProgressMonitor pm) throws IOException, DbxException {
final long fileLength = file.length();
Uploader uploader = null;
pm.begin(fileLength);
final DbxWriteMode writeMode = overwrite ? DbxWriteMode.force() : DbxWriteMode.update(parent_rev);
try (InputStream in = new FileInputStream(file)) {
uploader = client.startUploadFile(path, writeMode, fileLength);
final OutputStream body = uploader.getBody();
final byte[] buffer = new byte[bufferSize];
int read = 0;
while ((read = in.read(buffer)) > -1) {
body.write(buffer, 0, read);
pm.worked(read);
}
uploader.finish();
} finally {
close(uploader);
}
}
示例5: uploadFile
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
private void uploadFile(DbxClient client, String dropboxPath, boolean overwrite) throws DbxException, IOException {
File file = new File(contentDir + File.separator + dropboxPath);
FileInputStream inputStream = new FileInputStream(file);
try {
DbxWriteMode mode = overwrite ? DbxWriteMode.force() : DbxWriteMode.add();
DbxEntry.File uploadedFile =
client.uploadFile(dropboxPath, mode, file.length(), inputStream);
logger.debug("successfully uploaded file '{}'. New revision is '{}'", uploadedFile.toString(), uploadedFile.rev);
} finally {
inputStream.close();
}
}
示例6: finalizeUpload
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
public void finalizeUpload(MultiPartUpload mpu) {
try {
String path = (String) mpu.getObject("path");
String id = (String) mpu.getObject("id");
dbClient.chunkedUploadFinish(path, DbxWriteMode.add(), id);
} catch (DbxException ex) {
ex.printStackTrace();
}
}
示例7: upload_stream
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public static DbxEntry.File upload_stream(InputStream in, long size, String dest, DbxClient client) throws DbxException, IOException {
if(client == null)
throw new DbxException("Client not connected.");
DbxEntry.File outfile = null;
DbxClient.Uploader uploader = client.startUploadFile(dest, DbxWriteMode.force(), size);
try {
byte[] buffer = new byte[4096];
int bytes_read = -1;
int total_read = 0;
int amount_to_write = 0;
while((bytes_read = in.read(buffer, 0, 4096)) != -1)
{
amount_to_write = bytes_read;
if(bytes_read + total_read > size)
amount_to_write = total_read - bytes_read;
uploader.getBody().write(buffer, 0, amount_to_write);
total_read += bytes_read;
if(total_read > size)
break;
}
outfile = uploader.finish();
} finally {
uploader.close();
}
return outfile;
}
示例8: uploadFile
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
private void uploadFile(DbxClient client, String dropboxPath, boolean overwrite) throws DbxException, IOException {
File file = new File(contentDir + File.separator + dropboxPath);
FileInputStream inputStream = new FileInputStream(file);
try {
DbxWriteMode mode = overwrite ? DbxWriteMode.force() : DbxWriteMode.add();
DbxEntry.File uploadedFile = client.uploadFile(dropboxPath, mode, file.length(), inputStream);
logger.debug("Successfully uploaded file '{}'. New revision is '{}'.", uploadedFile, uploadedFile.rev);
} finally {
inputStream.close();
}
}
示例9: uploadDocument
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public void uploadDocument(DbxClient client, File inputFile, String outputFile) throws Exception {
FileInputStream inputStream = new FileInputStream(inputFile);
try {
DbxEntry.File uploadedFile = client.uploadFile(outputFile, DbxWriteMode.add(), inputFile.length(), inputStream);
log(" - Uploaded: " + uploadedFile.toString());
} finally {
inputStream.close();
}
}
示例10: getOutputStream
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
public OutputStream getOutputStream(URI uri) throws PluginException {
DbxClient.Uploader uploader = client.startUploadFileChunked(uri.getPath(), DbxWriteMode.force(), -1);
return new DropboxOutputStream(uploader);
}
示例11: upload
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public File upload(final long length, final InputStream is, final String fileName) throws DbxException, IOException {
final String path = this.endpoint.getPath();
return client.uploadFile(path + "/" + fileName, DbxWriteMode.add(), length, is);
}
示例12: call
import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
protected final void call(final DbxClient client, final ProgressMonitor pm) throws IOException, DbxException {
pm.begin(1);
final DbxWriteMode writeMode = overwrite ? DbxWriteMode.force() : DbxWriteMode.update(parent_rev);
client.chunkedUploadFinish(path, writeMode, upload_id);
}