Skip to content

Commit 270670c

Browse files
committed
Expand API to send original file size.
So we have a double guarantee about the content. Signed-off-by: David Calavera <[email protected]>
1 parent f27b426 commit 270670c

File tree

6 files changed

+74
-9
lines changed

6 files changed

+74
-9
lines changed

Makefile

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
.PHONY: all build deps generate help test validate
22
CHECK_FILES?=$$(go list ./... | grep -v /vendor/)
33

4-
5-
6-
74
help: ## Show this help.
85
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
96

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It's still a work in progress and we welcome feedback and contributions.
88

99
## Usage
1010

11-
The [`swagger.yml`](swagger.yml) file is the master copy of the Open API 2.0 definition. Additional context on using the API can be found on our [docs site](https://www.netlify.com/docs/api/).
11+
The [`swagger.yml`](swagger.yml) file is the master copy of the Open API 2.0 definition. Additional context on using the API can be found on our [docs site](https://www.netlify.com/docs/api/).
1212

1313
The spec is published and versioned for various ecosystems:
1414

go/plumbing/operations/upload_deploy_file_parameters.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/plumbing/operations/upload_deploy_function_parameters.go

+31-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
type uploadType int
4545
type pointerData struct {
4646
SHA string
47-
Size int
47+
Size int64
4848
}
4949

5050
type DeployObserver interface {
@@ -91,7 +91,7 @@ type FileBundle struct {
9191
Name string
9292
Sum string
9393
Runtime string
94-
Size *int `json:"size,omitempty"`
94+
Size *int64 `json:"size,omitempty"`
9595

9696
// Path OR Buffer should be populated
9797
Path string
@@ -416,6 +416,9 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
416416
if operationError == nil {
417417
defer body.Close()
418418
params := operations.NewUploadDeployFileParams().WithDeployID(d.ID).WithPath(f.Name).WithFileBody(body)
419+
if f.Size != nil {
420+
params.WithSize(f.Size)
421+
}
419422
if timeout != 0 {
420423
params.SetTimeout(timeout)
421424
}
@@ -701,7 +704,7 @@ func readLFSData(file io.Reader) (*pointerData, error) {
701704

702705
sha = strings.SplitN(oid, ":", 2)[1]
703706

704-
size, err := strconv.Atoi(values["size"])
707+
size, err := strconv.ParseInt(values["size"], 10, 0)
705708
if err != nil {
706709
return nil, err
707710
}

swagger.yml

+6
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ paths:
757757
type: string
758758
in: path
759759
required: true
760+
- name: size
761+
type: integer
762+
in: query
760763
- name: file_body
761764
in: body
762765
schema:
@@ -787,6 +790,9 @@ paths:
787790
- name: runtime
788791
type: string
789792
in: query
793+
- name: size
794+
type: integer
795+
in: query
790796
- name: file_body
791797
in: body
792798
schema:

0 commit comments

Comments
 (0)