因为上传到OBS要获取绝对路径,绝对路径是不可能从客户端哪里获取到得
所以这有上面办法获取到呢
public SysResult formFile(String fileUrl ) throws IOException {
/* 创建OBS客户端 */
ObsClient obsClient = new ObsClient(ak,sk,endPoint);
ObsBucket obsBucket;
try
{
/* 创建一个桶 */
obsBucket = createBucket(obsClient);
/* 上传文件到桶里面 */
String urlDecode = uploadFile(obsClient, obsBucket , fileUrl);
/* 列举对象(文件)的信息 */
// listFile(obsClient,obsBucket);
/* 关闭客户端 */
closeObsClient(obsClient);
System.out.println("读取该已上传对象的URL" + urlDecode);
return SysResult.ok(urlDecode);
}
catch (ObsException e)
{
return SysResult.build( 201,"上传失败" );
}
}