com.netease.cloud.services.nos.tools
public class noscmd extends Object
Constructor and Description |
---|
noscmd() |
Modifier and Type | Method and Description |
---|---|
void |
copyObject(String sourceBucketName,
String sourceKey,
String destinationBucketName,
String destinationKey)
copy an object to another bucket
|
void |
createBucket(String bucketName,
String location,
String acl)
create NOS bucket
|
void |
decodeRequestId(String rid)
decode a request id, output timestamp, ip address, etc
|
void |
deleteBucket(String bucketName)
delete the bucket
|
void |
deleteObject(String bucketName,
String key)
delete an object in specified bucket
|
boolean |
doesObjectExist(String bucket,
String object) |
String |
getAndIncrementLogSeq() |
void |
getBucketAcl(String bucketName)
get the acl of specified bucket,return 'public-read' or 'private'
|
String |
getLogID() |
String |
getLogSeq() |
void |
getObject(String bucketName,
String key,
String fileStr)
download the file in specified bucket
|
String |
getObjectKey(File f,
File directory)
guess objectkey for local files
|
void |
getObjects(String bucket,
File directory,
String prefix,
boolean isCover) |
byte[] |
i2b(int value)
int���������4������byte������
|
String |
ip2String(int ip) |
void |
listBucket()
list all your bucket
|
void |
listObjects(String bucketName,
String prefix,
List<String> keys)
list all object in specified bucket
|
void |
listObjects(String bucketName,
String prefix,
String marker,
int maxkeys) |
void |
localNotHave(String localDir,
String bucket) |
void |
lookup(String bucketName,
String key)
view a bucket or object ia exist or not.
|
static void |
main(String[] args) |
void |
moveObject(String sourceBucketName,
String sourceKey,
String destinationBucketName,
String destinationKey)
move an object to another bucket
|
void |
nosNotHave(String localDir,
Set<String> nosFileSizes,
Set<String> nosEtags,
String parent) |
void |
nosNotHave(String localDir,
String bucket) |
static String[] |
parseCommonParams(String[] args,
noscmd noscmd)
parse common parameters
|
void |
putFile(String bucketName,
String key,
File file,
boolean isCover)
upload file
|
void |
putStream(String bucketName,
String key,
String file)
upload data to specified bucket as an object,and support the stream way
|
void |
setBucketAcl(String bucketName,
String acl)
set the acl of the specified bucket
|
void |
setLogID(String logID) |
void |
setLogSeq(String logSeq) |
void |
uploadDir(String bucketName,
String virtualDirectoryKeyPrefix,
File directory,
boolean includeSubdirectories,
boolean iscover) |
static void |
usage() |
public static void usage()
public static void main(String[] args)
args
- public static String[] parseCommonParams(String[] args, noscmd noscmd)
args
- tool argumentsnoscmd
- nos command tool instancepublic void createBucket(String bucketName, String location, String acl)
bucketName
- the name of the bucketlocation
- the region of the bucket. 'HZ','BJ','GZ'dedup
- is deduplicate or not .'true' or 'false'acl
- access control. 'private' or 'public-read'public void putFile(String bucketName, String key, File file, boolean isCover) throws Exception
bucketName
- bucket of the uploaded file inkey
- the file name in bucketfile
- actual file need to be uploadedException
public void putStream(String bucketName, String key, String file) throws Exception
bucketName
- bucketName bucket of the uploaded file inkey
- the file name in bucketfile
- conditianla,file actual file need to be uploaded,the parameter
is null ,then read data from stdinException
public void getObject(String bucketName, String key, String fileStr) throws Exception
bucketName
- key
- fileStr
- Exception
public void deleteBucket(String bucketName)
bucketName
- public void deleteObject(String bucketName, String key)
bucketName
- key
- public void listObjects(String bucketName, String prefix, List<String> keys)
bucketName
- public void getObjects(String bucket, File directory, String prefix, boolean isCover) throws IOException
IOException
public void getBucketAcl(String bucketName)
bucketName
- public void listBucket()
public void lookup(String bucketName, String key)
bucketName
- key
- objectKey, if null, check bucket existence.public void setBucketAcl(String bucketName, String acl)
bucketName
- acl
- public void copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey)
sourceBucketName
- sourceKey
- destinationBucketName
- destinationKey
- public void moveObject(String sourceBucketName, String sourceKey, String destinationBucketName, String destinationKey)
sourceBucketName
- sourceKey
- destinationBucketName
- destinationKey
- public void localNotHave(String localDir, String bucket) throws NoSuchAlgorithmException, FileNotFoundException, IOException
public void nosNotHave(String localDir, String bucket) throws NoSuchAlgorithmException, FileNotFoundException, IOException
public void nosNotHave(String localDir, Set<String> nosFileSizes, Set<String> nosEtags, String parent) throws NoSuchAlgorithmException, FileNotFoundException, IOException
public String getObjectKey(File f, File directory)
f
- sub directory and filedirectory
- root directorypublic void uploadDir(String bucketName, String virtualDirectoryKeyPrefix, File directory, boolean includeSubdirectories, boolean iscover) throws ServiceException, ClientException, InterruptedException
public void decodeRequestId(String rid) throws org.apache.commons.codec.DecoderException
rid
- request idorg.apache.commons.codec.DecoderException
public String ip2String(int ip)
public byte[] i2b(int value)
value
- public String getLogID()
public void setLogID(String logID)
public String getLogSeq()
public String getAndIncrementLogSeq()
public void setLogSeq(String logSeq)
Copyright © 2017. All Rights Reserved.