Unable to upload local json file to mapbox using tileset Uploads API

泄露秘密 提交于 2019-12-07 07:56:28

Ok, so I was passing wrong key and was not setting the sessionToken. Following changes I made, and it is working now:

...
var key = (string)mbS3Credentials["key"];
var sessionToken = (string)mbS3Credentials["sessionToken"];
...
var amazonS3Uploader = new AmazonS3Uploader(accessKeyId, secretAccessKey, sessionToken, url);
...


 public AmazonS3Uploader(string accessKeyId, string secretAccessKey, string sessionToken, string serviceUrl)
        {
            var s3Config = new AmazonS3Config
            {
                ServiceURL = serviceUrl,
                RegionEndpoint = RegionEndpoint.USEast1,
                ForcePathStyle = true,
            };
            _s3Client = new AmazonS3Client(accessKeyId, secretAccessKey, sessionToken, s3Config);
        }

public void UploadFile(string filePath, string s3BucketName, string key, string newFileName, bool deleteLocalFileOnSuccess)
        {
            //save in s3
            var s3PutRequest = new PutObjectRequest
            {
                FilePath = filePath,
                BucketName = s3BucketName,
                Key = key,
                CannedACL = S3CannedACL.PublicRead
            };

            //key - new file name
            //if (!string.IsNullOrWhiteSpace(newFileName))
            //{
            //    s3PutRequest.Key = newFileName;
            //}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!