云函数可以用 db.collection('activity').aggregate() .match({reg_time:_.lte(new Date())})
云函数中数据库查询进行日期比较查询- 需求的场景描述(希望解决的问题) 1.云函数中如何进行日期比较,希望官方给出示例。 - 希望提供的能力 1.返回云函数中查询大于某个日期的数据 2.企业微信用户进入小程度,能方便获得通讯录身份
2020-12-21String fileName= (String) params.get("fileName"); //获取上传连接 String url="https://api.weixin.qq.com/tcb/uploadfile?access_token="+ URLEncoder.encode(URLEncoder.encode(Constants.getAccessToken())); JsonObject param=new JsonObject(); param.addProperty("env",Constants.wx_config_env); param.addProperty("path",(String)params.get("path")); String result=new HttpRequestUtil().request(url,"post",param); System.out.println(result); final JsonObject resJson=new Gson().fromJson(result,JsonObject.class); if(resJson.get("errcode")!=null && resJson.get("errcode").getAsInt()==0){//获取上传链接成功 String uploadUrl=resJson.get("url").getAsString(); String TYPE = "application/octet-stream"; // byte file[]=Base64Utils.decodeFromString(base64.substring(base64.indexOf(",")+1)); RequestBody fileBody = RequestBody.create(MediaType.parse(TYPE), file); okhttp3.MultipartBody.Builder builder = new okhttp3.MultipartBody.Builder(); MultipartBody multipartBody = builder.setType(MultipartBody.FORM) .addFormDataPart("key",param.get("path").getAsString()) .addFormDataPart("Signature",resJson.get("authorization").getAsString()) .addFormDataPart("x-cos-security-token",resJson.get("token").getAsString()) .addFormDataPart("x-cos-meta-fileid",resJson.get("cos_file_id").getAsString()) .addFormDataPart("file",URLEncoder.encode(fileName),fileBody).build(); Request request1= (new Request.Builder()).url(uploadUrl).post(multipartBody).build(); OkHttpClient.Builder b=new okhttp3.OkHttpClient.Builder(); OkHttpClient okHttpClient=b.build(); Response response1 = okHttpClient.newCall(request1).execute();
有谁有java调用云开发HTTP api上传文件的代码样例?我在用java调用云开发HTTPAPI上传文件时,总返回400错误,麻烦大神帮忙看下问题出在哪? import cn.hutool.json.JSONObject; import com.dimon.cloud.commons.rest.ApiResponse; import com.dimon.cloud.customize.feign.WechatApi; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotNull; import java.io.IOException; /** * @Author: He Zhigang * @Date: 2019/10/12 18:00 * @Description: */ @RestController public class BackendController { @Autowired String accessToken; @Autowired WechatApi wechatApi; @PostMapping("/upload/prod/img") public ApiResponse uploadFile(@NotNull MultipartFile file) throws IOException { String dir = "p_cust/prod/img/"; String path = dir + file.getOriginalFilename(); JSONObject reqBody = new JSONObject(); reqBody.put("env", "dev-4cs4fs"); reqBody.put("path", path); JSONObject respJson = wechatApi.uploadFile(accessToken, reqBody); String url = respJson.getStr("url"); // HttpResponse httpResponse = HttpRequest.post(url) // .contentType("multipart/form-data") // .header("Content-Type", "multipart/form-data") // .form("key", path) // .form("Signature", respJson.getStr("authorization")) // .form("x-cos-security-token", respJson.getStr("token")) // .form("x-cos-meta-fileid", respJson.getStr("cos_file_id")) // .form("file", file) // .execute(); HttpClient httpClient = HttpClientBuilder.create().build(); HttpPost httpPost = new HttpPost(url); httpPost.setHeader("Content-Type", "multipart/form-data"); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", file.getBytes()) .addTextBody("key", path) .addTextBody("Signature", respJson.getStr("authorization")) .addTextBody("x-cos-security-token", respJson.getStr("token")) .addTextBody("x-cos-meta-fileid", respJson.getStr("cos_file_id")); httpPost.setEntity(builder.build()); org.apache.http.HttpResponse res = httpClient.execute(httpPost); return ApiResponse.ok().setBody(res); } } 上面我用了两种不同的HTTP client 都是返回同样的错误。[图片]
2020-12-201.03.2012112,点击云开发没反应,开发工具调试控制台报错:未开通腾讯云帐号
开发工具点击云开发无反应?我的开发工具点击云开发无反应,没见到云开发控制台,我已开通云开发啦!
2020-12-12