Java tutorial
/** * Copyright 2018 ? http://www.renren.io * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package io.renren.modules.oss.cloud; import io.renren.common.utils.DateUtils; import org.apache.commons.lang.StringUtils; import java.io.InputStream; import java.util.Date; import java.util.UUID; /** * (??????) * @author chenshun * @email sunlightcs@gmail.com * @date 2017-03-25 14:58 */ public abstract class CloudStorageService { /** ?? */ CloudStorageConfig config; /** * * @param prefix ? * @param suffix ? * @return */ public String getPath(String prefix, String suffix) { //?uuid String uuid = UUID.randomUUID().toString().replaceAll("-", ""); // String path = DateUtils.format(new Date(), "yyyyMMdd") + "/" + uuid; if (StringUtils.isNotBlank(prefix)) { path = prefix + "/" + path; } return path + suffix; } /** * * @param data * @param path ??? * @return http? */ public abstract String upload(byte[] data, String path); /** * * @param data * @param suffix ? * @return http? */ public abstract String uploadSuffix(byte[] data, String suffix); /** * * @param inputStream ? * @param path ??? * @return http? */ public abstract String upload(InputStream inputStream, String path); /** * * @param inputStream ? * @param suffix ? * @return http? */ public abstract String uploadSuffix(InputStream inputStream, String suffix); }