本文整理汇总了Java中com.dropbox.client2.DropboxAPI.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java DropboxAPI.Entry方法的具体用法?Java DropboxAPI.Entry怎么用?Java DropboxAPI.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dropbox.client2.DropboxAPI
的用法示例。
在下文中一共展示了DropboxAPI.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFiles
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public List<String> listFiles() throws Exception {
if (authSession()) {
try {
List<String> files = new ArrayList<>();
List<DropboxAPI.Entry> entries = dropboxApi.search("/", ".backup", 1000, false);
for (DropboxAPI.Entry entry : entries) {
if (entry.fileName() != null) {
files.add(entry.fileName());
}
}
Collections.sort(files, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s2.compareTo(s1);
}
});
return files;
} catch (Exception e) {
Log.e("Flowzr", "Dropbox: Something wrong", e);
throw new ImportExportException(R.string.dropbox_error, e);
}
} else {
throw new ImportExportException(R.string.dropbox_auth_error);
}
}
示例2: uploadFile
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
/**
* A helper method that uploads a file whose path is passed as parameter to Dropbox.
*
* @param path Path to the file that should be uploaded to Dropbox.
* @throws FileNotFoundException If {@code file} does not exist.
* @throws DropboxException If a Dropbox related exception occurs.
*/
private void uploadFile(String path) throws FileNotFoundException, DropboxException {
File file = new File(path);
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
DropboxAPI.Entry response = dropboxApi.putFile('/' + file.getName(), inputStream, file.length(), null, null);
Log.i(TAG, "uploadFile() :: The uploaded file's rev is: " + response.rev);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
示例3: testRemoteFileMissing
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public void testRemoteFileMissing() {
DropboxAPI<?> dropboxapi = new DropboxAPIStub() {
public DropboxAPI.Entry metadata(String arg0, int arg1,
String arg2, boolean arg3, String arg4)
throws DropboxException {
throw notFoundException();
}
};
DropboxFileDownloader downloader = new DropboxFileDownloader(
dropboxapi, dropboxFiles1);
downloader.pullFiles();
assertEquals("Status should be SUCCESS", DropboxFileStatus.SUCCESS,
downloader.getStatus());
assertEquals("Should have 1 file", 1, downloader.getFiles().size());
assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
dbFile1.getStatus());
}
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:20,代码来源:DropboxFileDownloaderTest.java
示例4: testRemoteFileDeleted
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public void testRemoteFileDeleted() {
DropboxAPI<?> dropboxapi = new DropboxAPIStub() {
public DropboxAPI.Entry metadata(String arg0, int arg1,
String arg2, boolean arg3, String arg4)
throws DropboxException {
return create_metadata(remoterev1, true);
}
};
DropboxFileDownloader downloader = new DropboxFileDownloader(
dropboxapi, dropboxFiles1);
downloader.pullFiles();
assertEquals("Status should be SUCCESS", DropboxFileStatus.SUCCESS,
downloader.getStatus());
assertEquals("Should have 1 file", 1, downloader.getFiles().size());
assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
dbFile1.getStatus());
}
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:20,代码来源:DropboxFileDownloaderTest.java
示例5: testBothFilesMissing
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public void testBothFilesMissing() {
DropboxAPI<?> dropboxapi = new DropboxAPIStub() {
public DropboxAPI.Entry metadata(String arg0, int arg1,
String arg2, boolean arg3, String arg4)
throws DropboxException {
throw notFoundException();
}
};
DropboxFileDownloader downloader = new DropboxFileDownloader(
dropboxapi, dropboxFiles2);
downloader.pullFiles();
assertEquals("Status should be SUCCESS", DropboxFileStatus.SUCCESS,
downloader.getStatus());
assertEquals("Should have 2 files", 2, downloader.getFiles().size());
assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
dbFile1.getStatus());
assertEquals("Status should be NOT_FOUND", DropboxFileStatus.NOT_FOUND,
dbFile2.getStatus());
}
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:22,代码来源:DropboxFileDownloaderTest.java
示例6: getFilesInDir
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public Set<String> getFilesInDir(String dirName, String query)
{
Set<String> retVal = null;
if( isConnected() ) {
try {
Log.d(TAG, "Getting files in: " + dirName);
DropboxAPI.Entry entries = mDBApi.metadata("/" + dirName, MAX_DROPBOX_FILES, null, true, null);
// Move list of files into hashset
retVal = new HashSet<String>();
for( DropboxAPI.Entry entry : entries.contents )
{
retVal.add( entry.fileName() );
}
} catch( DropboxException e )
{
e.printStackTrace();
}
}
return retVal;
}
示例7: fileExists
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public boolean fileExists(String fileName)
{
boolean retVal = false;
if( isConnected() ) {
try {
DropboxAPI.Entry existingEntry = mDBApi.metadata("/" + fileName, 1, null, false, null);
if ((!existingEntry.isDir) && (!existingEntry.isDeleted)) {
retVal = true;
}
} catch( DropboxException e )
{
e.printStackTrace();
}
}
return retVal;
}
示例8: getRemoteEntries
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
@Override
public List<RemoteDataInfo> getRemoteEntries() throws SyncFailedException {
StringBuilder sb = new StringBuilder();
sb.append(getBaseFilePath());
sb.append(ENTRIES);
List<RemoteDataInfo> dataInfoObjects = new ArrayList<>();
try {
List<DropboxAPI.Entry> dropboxEntries = getFileInfo(sb.toString()).contents;
for (DropboxAPI.Entry entry : dropboxEntries) {
if ( !entry.isDir ) {
RemoteDataInfo infoObject = new RemoteDataInfo();
infoObject.isDirectory = entry.isDir;
infoObject.isDeleted = entry.isDeleted;
infoObject.name = entry.fileName().toUpperCase();
infoObject.modifiedDate = RESTUtility.parseDate(entry.modified).getTime();
infoObject.revision = entry.rev;
dataInfoObjects.add(infoObject);
}
}
} catch (Exception e) {
if (!BuildConfig.DEBUG) Crashlytics.logException(e);
e.printStackTrace();
throw new SyncFailedException(e.getMessage());
}
return dataInfoObjects;
}
示例9: getRemotePhotos
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
@Override
public List<RemoteDataInfo> getRemotePhotos() throws SyncFailedException {
StringBuilder sb = new StringBuilder();
sb.append(getBaseFilePath());
sb.append(PHOTOS);
List<RemoteDataInfo> dataInfoObjects = new ArrayList<>();
try {
List<DropboxAPI.Entry> dropboxEntries = getFileInfo(sb.toString()).contents;
for (DropboxAPI.Entry file : dropboxEntries) {
if ( !file.isDir ) {
RemoteDataInfo infoObject = new RemoteDataInfo();
infoObject.isDirectory = file.isDir;
infoObject.isDeleted = file.isDeleted;
infoObject.name = file.fileName().toLowerCase();
infoObject.modifiedDate = RESTUtility.parseDate(file.modified).getTime();
infoObject.revision = file.rev;
dataInfoObjects.add(infoObject);
}
}
} catch (Exception e) {
if (!BuildConfig.DEBUG) Crashlytics.logException(e);
e.printStackTrace();
throw new SyncFailedException(e.getMessage());
}
return dataInfoObjects;
}
示例10: doesFolderExist
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
private boolean doesFolderExist(String path) {
try {
DropboxAPI.Entry metadata = getFileInfo(path);
return metadata.isDir;
} catch (DropboxException e) {
e.printStackTrace();
return false;
}
}
示例11: doesFileExist
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
/**
* Returns 1 if it does exist
* Returns 0 if it does not exist
* Returns -1 if there is any other error
*
* @param path
* @return
*/
private int doesFileExist(String path) {
try {
DropboxAPI.Entry metadata = getFileInfo(path);
return 1;
} catch (DropboxException e) {
e.printStackTrace();
if (e.toString().contains("404"))
return 0;
else
return -1;
}
}
示例12: searchFile
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
@Override
public synchronized List<SearchResult> searchFile(int categary, String query) throws RemoteStorageException {
String categaryDir = categaryDirs[categary];
List<SearchResult> searchResults = new ArrayList<SearchResult>();
try {
initServers();
for (DropboxServer dropboxServer : secondaryServers) {
initSession(dropboxServer);
for (int i = 0; i < subCategaryDirs.length; i++) {
String subCategaryDir = subCategaryDirs[i];
List<DropboxAPI.Entry> dropboxResults = dropboxAPI.search("/" + categaryDir
+ "/" + subCategaryDir,
query,
MAX_SEARCH_RESULTS,
false);
for (DropboxAPI.Entry entry : dropboxResults) {
SearchResult result = new SearchResult(
entry.fileName(),
entry.parentPath() + "/" + entry.fileName(),
categary,
i,
dropboxServer);
entry.parentPath();
searchResults.add(result);
}
}
}
} catch (DropboxException ex) {
Logger.getLogger(DropboxSdk.class.getName()).log(Level.SEVERE, null, ex);
throw new RemoteStorageException(ex);
}
return searchResults;
}
示例13: uploadFile
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
public void uploadFile(File file) throws Exception {
if (authSession()) {
try {
InputStream is = new FileInputStream(file);
DropboxAPI.Entry newEntry = dropboxApi.putFile(file.getName(), is, file.length(), null, null);
Log.i("Flowzr", "Dropbox: The uploaded file's rev is: " + newEntry.rev);
} catch (Exception e) {
Log.e("Flowzr", "Dropbox: Something wrong", e);
throw new ImportExportException(R.string.dropbox_error, e);
}
} else {
throw new ImportExportException(R.string.dropbox_auth_error);
}
}
示例14: create_metadata
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
private DropboxAPI.Entry create_metadata(String path, String rev, boolean isDeleted) {
DropboxAPI.Entry metadata = new DropboxAPI.Entry();
metadata.path = path;
metadata.rev = rev;
metadata.isDeleted = isDeleted;
return metadata;
}
示例15: upload
import com.dropbox.client2.DropboxAPI; //导入方法依赖的package包/类
boolean upload( String fileName, InputStream in ) throws IOException, DropboxException
{
boolean allOk = true;
// TODO: Check that there's enough quota
DropboxAPI.Entry uploadedFileMetadata;
try {
DropboxAPI.ChunkedUploader uploader = mDBApi.getChunkedUploader(in);
int retryCounter = 0;
while(!uploader.isComplete()) {
try {
uploader.upload();
} catch (DropboxException e) {
if (retryCounter > MAX_RETRIES)
{
e.printStackTrace();
allOk = false;
break; // Give up after a while.
}
retryCounter++;
// Maybe wait a few seconds before retrying?
}
}
if( allOk ) {
uploadedFileMetadata = uploader.finish("/"+fileName, null);
Log.d(TAG, "Uploaded " + uploadedFileMetadata.fileName() + ", size: " + uploadedFileMetadata.size);
} else {
Log.d(TAG, "Upload of "+fileName+" failed");
}
} finally {
in.close();
}
return allOk;
}