首页 文章 精选 留言 我的

精选列表

搜索[header],共5459篇文章
优秀的个人博客,低调大师

OSS签名Header实现Demo(PHP)

概述 OSS的集成上传和下载提供了SDK可以直接使用,但实际使用中一些用户受限环境或者设备限制需要使用api方式来实现上传和下载,本文以PutObject接口为例,提供了PHP实现的demo。注:建议优先使用OSS提供SDK,本文提供的只是签名实现上传demo,实际使用中需要结合业务来进行改动代码 详细信息 PutObject实现Demo(测试环境php5.6.30): <?php function curlput($url,$data,$method='PUT',$bucket,$object,$accesskey ,$accesskeySecret){ $time = gmdate ("D, d M Y H:i:s T"); $str = "PUT\n\n"."application/json\n".$time."\n/".$bucket."/".$object; //echo($str); $signature = base64_encode(hash_hmac("sha1", $str, $accesskeySecret, true)); //echo($time); //echo($signature); $ch = curl_init(); //初始化CURL句柄 curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //设置请求方式 $headers = array( "Date:".$time, 'Content-Type:application/json', "Authorization:OSS ".$accesskey.":".$signature ); curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);//设置HTTP头信息 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//设置提交的字符串 $document = curl_exec($ch);//执行预定义的CURL if(!curl_errno($ch)){ $info = curl_getinfo($ch); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; } else { echo 'Curl error: ' . curl_error($ch); } curl_close($ch); return $document; } $accesskey ='xxx'; $accesskeySecret ='xxx'; $bucket = 'bucketname'; $object = 'mytest/2.txt'; $url = 'http://bucketname.oss-cn-hangzhou.aliyuncs.com/mytest/2.txt'; $data = "{wewwe:wewee}"; $return = curlput($url, $data, 'PUT',$bucket,$object,$accesskey,$accesskeySecret); var_dump($return); exit; ?>

优秀的个人博客,低调大师

OSS签名Header实现Demo(C#)

概述 OSS的集成上传和下载提供了SDK可以直接使用,但实际使用中一些用户受限环境或者设备限制需要使用api方式来实现上传和下载,本文以PutObject接口为例,提供了C#实现的demo。注:建议优先使用OSS提供SDK,本文提供的只是签名实现上传demo,实际使用中需要结合业务来进行改动代码详细信息PutObject实现demo(visual studio 2017,NET Framework4.0) using System; using System.Security.Cryptography; using System.Text; using System.Net; using System.IO; using System.Reflection; namespace Aliyun.OSS.Samples { class Program { //您的AccessKey public static string AccessKey = "xx"; //您的 AccessKeySecret public static string AccessKeySecret = "xx"; //bucket所在的endpoint public static string Endpoint = "oss-cn-hangzhou.aliyuncs.com"; public static string BucketName = "xx"; public static string objectName = "mytest/1.txt"; public static string HmacSha1Sign(string secret, string strOrgData) { var hmacsha1 = new HMACSHA1(Encoding.UTF8.GetBytes(secret)); var dataBuffer = Encoding.UTF8.GetBytes(strOrgData); var hashBytes = hmacsha1.ComputeHash(dataBuffer); return Convert.ToBase64String(hashBytes); } public static string HttpRequest(string url, string data, string sign, string contentType, string time1) { byte[] datas = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(data); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "PUT"; request.Timeout = 150000; request.Headers.Add("Authorization", "OSS " + AccessKey + ":" + sign); CallPrivateMethod(request, "SetSpecialHeaders", "Date", time1); request.ContentType = contentType; Stream requestStream = null; string responseStr = null; try { if (datas != null) { request.ContentLength = datas.Length; requestStream = request.GetRequestStream(); requestStream.Write(datas, 0, datas.Length); requestStream.Close(); } else { request.ContentLength = 0; } HttpWebResponse response = request.GetResponse() as HttpWebResponse; responseStr = response.Headers.GetValues("x-oss-request-id")[0]; //responseStr = sr.ReadToEnd(); } catch (Exception) { Console.WriteLine("error"); } finally { request = null; requestStream = null; } return responseStr; } public static string ToGMTString() { return DateTime.Now.ToUniversalTime().ToString("r"); } public static void CallPrivateMethod(object instance, string name, params object[] param) { BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic; Type type = instance.GetType(); MethodInfo method = type.GetMethod(name, flag); method.Invoke(instance, param); } static void Main(string[] args) { string varb = "PUT"; string content_type = "application/json"; string timeGmt = ToGMTString(); string str = varb + "\n\n" + content_type + "\n" + timeGmt + "\n/" + BucketName + "/" + objectName; string signature = HmacSha1Sign(AccessKeySecret, str); string url = "http://" + BucketName + "." + Endpoint + "/" + objectName; string data = "{ \"key\":\"this is a oss's test\"}"; string result = HttpRequest(url, data, signature, content_type, timeGmt); Console.WriteLine("requestId: " + result); } } }

优秀的个人博客,低调大师

错误消息sales area is not assigned for the header product

When I try to download customer material info record from ERP, I meet with this error message in tcode SMW01: The error message is raised due to the fact that in CRM, the corresponding sales organization for this product is not found. However, since this product itself is downloaded from ERP, you could NOT add any distribution chain to it manually. Go back to ERP and check table MVKE, we can find the sales organization 0001 and channel 01 is assigned to this product correctly. This indicates that the sales area for this material has not been downloaded to CRM successfully.So go to CRM, check Sales organization mapping in organization model, and found there is no entry configured for 0001-01.Add the missing entry in tcode PPOMA_CRM after that perform a request download once again, this time you should find in SMW01 that the sales area has successfully been downloaded. Now go back to WebUI, both two assignment block now display correct data from ERP: 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

Android 显示 WebView ,加载URL 时,向webview的 header 里面传递参数

1、主要布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".MainActivity"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent"> </WebView> </RelativeLayout> 2、代码实现 1 package com.webview.demo; 2 3 import android.os.Bundle; 4 import android.support.v7.app.AppCompatActivity; 5 import android.webkit.WebView; 6 7 import java.util.HashMap; 8 import java.util.Map; 9 10 public class MainActivity extends AppCompatActivity { 11 12 private WebView webView ; 13 14 private String webViewHeaderKey = "tokenId" ; 15 private String webViewHeaderValue = "562142" ; 16 17 private String url = "" ; 18 19 @Override 20 protected void onCreate(Bundle savedInstanceState) { 21 super.onCreate(savedInstanceState); 22 setContentView(R.layout.activity_main); 23 24 webView = (WebView) findViewById( R.id.webview ); 25 26 27 if ( webViewHeaderValue != "" ){ 28 Map<String, String > map = new HashMap<String, String>() ; 29 map.put( webViewHeaderKey , webViewHeaderValue ) ; 30 31 webView.loadUrl( url , map ) ; 32 }else { 33 webView.loadUrl( url ) ; 34 } 35 36 } 37 }

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册