Comparing version 3.1.0 to 3.1.1
@@ -27,3 +27,3 @@ import * as utils from './utils'; | ||
*/ | ||
export declare function initUploadParts(token: string, bucket: string, key: string, uploadUrl: string): utils.Response<InitPartsData>; | ||
export declare function initUploadParts(token: string, bucket: string, key: string | null | undefined, uploadUrl: string): utils.Response<InitPartsData>; | ||
export interface UploadChunkData { | ||
@@ -39,3 +39,3 @@ etag: string; | ||
*/ | ||
export declare function uploadChunk(token: string, key: string, index: number, uploadInfo: UploadInfo, options: Partial<utils.RequestOptions>): utils.Response<UploadChunkData>; | ||
export declare function uploadChunk(token: string, key: string | null | undefined, index: number, uploadInfo: UploadInfo, options: Partial<utils.RequestOptions>): utils.Response<UploadChunkData>; | ||
export declare type UploadCompleteData = any; | ||
@@ -48,3 +48,3 @@ /** | ||
*/ | ||
export declare function uploadComplete(token: string, key: string, uploadInfo: UploadInfo, options: Partial<utils.RequestOptions>): utils.Response<UploadCompleteData>; | ||
export declare function uploadComplete(token: string, key: string | null | undefined, uploadInfo: UploadInfo, options: Partial<utils.RequestOptions>): utils.Response<UploadCompleteData>; | ||
/** | ||
@@ -55,3 +55,3 @@ * @param token 上传鉴权凭证 | ||
*/ | ||
export declare function deleteUploadedChunks(token: string, key: string, uploadinfo: UploadInfo): utils.Response<void>; | ||
export declare function deleteUploadedChunks(token: string, key: string | null | undefined, uploadinfo: UploadInfo): utils.Response<void>; | ||
export {}; |
@@ -93,3 +93,3 @@ var __assign = (this && this.__assign) || function () { | ||
var url = uploadInfo.url, id = uploadInfo.id; | ||
return url + "/buckets/" + bucket + "/objects/" + urlSafeBase64Encode(key) + "/uploads/" + id; | ||
return url + "/buckets/" + bucket + "/objects/" + (key != null ? urlSafeBase64Encode(key) : '~') + "/uploads/" + id; | ||
} | ||
@@ -103,3 +103,3 @@ /** | ||
export function initUploadParts(token, bucket, key, uploadUrl) { | ||
var url = uploadUrl + "/buckets/" + bucket + "/objects/" + urlSafeBase64Encode(key) + "/uploads"; | ||
var url = uploadUrl + "/buckets/" + bucket + "/objects/" + (key != null ? urlSafeBase64Encode(key) : '~') + "/uploads"; | ||
return utils.request(url, { | ||
@@ -106,0 +106,0 @@ method: 'POST', |
@@ -14,3 +14,3 @@ import { Extra, Config, UploadProgress } from './upload'; | ||
*/ | ||
declare function upload(file: File, key: string, token: string, putExtra?: Partial<Extra>, config?: Partial<Config>): Observable<UploadProgress, CustomError, UploadCompleteData>; | ||
declare function upload(file: File, key: string | null | undefined, token: string, putExtra?: Partial<Extra>, config?: Partial<Config>): Observable<UploadProgress, CustomError, UploadCompleteData>; | ||
export { getHeadersForMkFile, getHeadersForChunkUpload } from './utils'; | ||
@@ -17,0 +17,0 @@ export { urlSafeBase64Encode, urlSafeBase64Decode } from './base64'; |
@@ -46,3 +46,3 @@ import * as utils from '../utils'; | ||
file: File; | ||
key: string; | ||
key: string | null | undefined; | ||
token: string; | ||
@@ -83,3 +83,3 @@ putExtra?: Partial<Extra>; | ||
protected file: File; | ||
protected key: string; | ||
protected key: string | null | undefined; | ||
protected aborted: boolean; | ||
@@ -86,0 +86,0 @@ protected retryCount: number; |
@@ -12,3 +12,3 @@ import { Progress, LocalInfo } from './upload'; | ||
export declare function setLocalFileInfo(localKey: string, info: LocalInfo): void; | ||
export declare function createLocalKey(name: string, key: string, size: number): string; | ||
export declare function createLocalKey(name: string, key: string | null | undefined, size: number): string; | ||
export declare function removeLocalFileInfo(localKey: string): void; | ||
@@ -15,0 +15,0 @@ export declare function getLocalFileInfo(localKey: string): LocalInfo | null; |
@@ -93,3 +93,4 @@ var __assign = (this && this.__assign) || function () { | ||
export function createLocalKey(name, key, size) { | ||
return "qiniu_js_sdk_upload_file_name_" + name + "_key_" + key + "_size_" + size; | ||
var localKey = key == null ? '_' : "_key_" + key + "_"; | ||
return "qiniu_js_sdk_upload_file_name_" + name + localKey + "size_" + size; | ||
} | ||
@@ -96,0 +97,0 @@ export function removeLocalFileInfo(localKey) { |
@@ -256,3 +256,3 @@ "use strict"; | ||
id = uploadInfo.id; | ||
return url + "/buckets/" + bucket + "/objects/" + (0, _base.urlSafeBase64Encode)(key) + "/uploads/" + id; | ||
return url + "/buckets/" + bucket + "/objects/" + (key != null ? (0, _base.urlSafeBase64Encode)(key) : '~') + "/uploads/" + id; | ||
} | ||
@@ -268,3 +268,3 @@ /** | ||
function initUploadParts(token, bucket, key, uploadUrl) { | ||
var url = uploadUrl + "/buckets/" + bucket + "/objects/" + (0, _base.urlSafeBase64Encode)(key) + "/uploads"; | ||
var url = uploadUrl + "/buckets/" + bucket + "/objects/" + (key != null ? (0, _base.urlSafeBase64Encode)(key) : '~') + "/uploads"; | ||
return utils.request(url, { | ||
@@ -271,0 +271,0 @@ method: 'POST', |
@@ -278,3 +278,4 @@ "use strict"; | ||
function createLocalKey(name, key, size) { | ||
return "qiniu_js_sdk_upload_file_name_" + name + "_key_" + key + "_size_" + size; | ||
var localKey = key == null ? '_' : "_key_" + key + "_"; | ||
return "qiniu_js_sdk_upload_file_name_" + name + localKey + "size_" + size; | ||
} | ||
@@ -281,0 +282,0 @@ |
{ | ||
"name": "qiniu-js", | ||
"jsName": "qiniu", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP", |
# Qiniu-JavaScript-SDK | ||
[![Build Status](https://travis-ci.org/qiniu/x.svg?branch=master)](https://travis-ci.org/qiniu/js-sdk) | ||
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/js-sdk.svg?label=release)](https://github.com/qiniu/js-sdk/releases) | ||
[![Coverage Status](https://codecov.io/gh/qiniu/js-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/js-sdk) | ||
基于七牛 API 开发的前端 JavaScript SDK | ||
@@ -8,3 +12,2 @@ | ||
## 快速导航 | ||
@@ -181,3 +184,3 @@ | ||
* **file**: `File` 对象,上传的文件 | ||
* **key**: 文件资源名 | ||
* **key**: 文件资源名,为空字符串时则文件资源名也为空,为 `null` 或者 `undefined` 时则自动使用文件的 `hash` 作为文件名 | ||
* **token**: 上传验证信息,前端通过接口请求后端获得 | ||
@@ -184,0 +187,0 @@ * **config**: `object`,其中的每一项都为可选 |
@@ -46,5 +46,5 @@ import * as utils from './utils' | ||
*/ | ||
function getBaseUrl(bucket: string, key: string, uploadInfo: UploadInfo) { | ||
function getBaseUrl(bucket: string, key: string | null | undefined, uploadInfo: UploadInfo) { | ||
const { url, id } = uploadInfo | ||
return `${url}/buckets/${bucket}/objects/${urlSafeBase64Encode(key)}/uploads/${id}` | ||
return `${url}/buckets/${bucket}/objects/${key != null ? urlSafeBase64Encode(key) : '~'}/uploads/${id}` | ||
} | ||
@@ -68,6 +68,6 @@ | ||
bucket: string, | ||
key: string, | ||
key: string | null | undefined, | ||
uploadUrl: string | ||
): utils.Response<InitPartsData> { | ||
const url = `${uploadUrl}/buckets/${bucket}/objects/${urlSafeBase64Encode(key)}/uploads` | ||
const url = `${uploadUrl}/buckets/${bucket}/objects/${key != null ? urlSafeBase64Encode(key) : '~'}/uploads` | ||
return utils.request<InitPartsData>( | ||
@@ -95,3 +95,3 @@ url, | ||
token: string, | ||
key: string, | ||
key: string | null | undefined, | ||
index: number, | ||
@@ -120,3 +120,3 @@ uploadInfo: UploadInfo, | ||
token: string, | ||
key: string, | ||
key: string | null | undefined, | ||
uploadInfo: UploadInfo, | ||
@@ -141,3 +141,3 @@ options: Partial<utils.RequestOptions> | ||
token: string, | ||
key: string, | ||
key: string | null | undefined, | ||
uploadinfo: UploadInfo | ||
@@ -144,0 +144,0 @@ ): utils.Response<void> { |
@@ -20,3 +20,3 @@ import StatisticsLogger from './statisticsLog' | ||
file: File, | ||
key: string, | ||
key: string | null | undefined, | ||
token: string, | ||
@@ -23,0 +23,0 @@ putExtra?: Partial<Extra>, |
@@ -47,3 +47,3 @@ import * as utils from '../utils' | ||
file: File | ||
key: string | ||
key: string | null | undefined | ||
token: string | ||
@@ -92,3 +92,3 @@ putExtra?: Partial<Extra> | ||
protected file: File | ||
protected key: string | ||
protected key: string | null | undefined | ||
protected aborted = false | ||
@@ -95,0 +95,0 @@ protected retryCount = 0 |
@@ -56,4 +56,5 @@ import SparkMD5 from 'spark-md5' | ||
export function createLocalKey(name: string, key: string, size: number): string { | ||
return `qiniu_js_sdk_upload_file_name_${name}_key_${key}_size_${size}` | ||
export function createLocalKey(name: string, key: string | null | undefined, size: number): string { | ||
const localKey = key == null ? '_' : `_key_${key}_` | ||
return `qiniu_js_sdk_upload_file_name_${name}${localKey}size_${size}` | ||
} | ||
@@ -60,0 +61,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2315077
153
27757
507