package com.vulcan.controller.attachment;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.obs.services.ObsClient;
import com.obs.services.exception.ObsException;
import com.obs.services.model.ObsObject;
import com.vulcan.base.BaseController;
import com.vulcan.common.util.oss.OBSClient;
import com.vulcan.common.util.oss.OSSClientUtil;
import com.vulcan.common.util.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @描述:上传下载
* @创建时间:2019年04月16日
* @Copyright @2019 by lzh
*/
@Controller
@RequestMapping("/web/attachment")
@Slf4j
public class Attachment extends BaseController {
@Autowired
OSSClientUtil ossClientUtil;
/**
* 5M
*/
private static final int MAX_POST_SIZE = 5 * 1024 * 1024;
/**
* 100M
*/
private static final int MAX_POST_SIZE_FILE = 100 * 1024 * 1024;
public static synchronized String getOrder() {
return DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS") + RandomStringUtils.randomNumeric(6);
}
/**
* 上传图片
*
* @param file
* @return
*/
@ResponseBody
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public Result spri
华为OBS、阿里云OSS文件图片上传下载
最新推荐文章于 2024-09-26 10:54:16 发布
本文详细介绍了如何使用华为Object Storage Service (OBS) 和阿里云Object Storage Service (OSS) 进行文件及图片的上传和下载操作。内容包括配置步骤、API调用示例以及常见问题解决,旨在帮助开发者更好地理解和应用这两款云存储服务。
摘要由CSDN通过智能技术生成