-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for uploading blob item's data #254
Conversation
@@ -25,9 +25,9 @@ export interface IItemIdRequestOptions extends IUserRequestOptions { | |||
owner?: string; | |||
} | |||
|
|||
export interface IItemJsonDataRequestOptions extends IItemIdRequestOptions { | |||
export interface IItemJsonRequestOptions extends IItemIdRequestOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to convey that it supports both JSON object literals and blobs, would IItemDataRequestOptions
be a better (re)name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the intention--I erred.
*/ | ||
export function addItemBinaryData( | ||
requestOptions: IItemJsonRequestOptions | ||
): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a lot of Promise<any>
in this package, but since we know what the signature of the response will be, it'd be good to be explicit about what this method returns.
export function addItemBinaryData( | ||
requestOptions: IItemJsonRequestOptions | ||
): Promise<any> { | ||
const owner = requestOptions.owner || requestOptions.authentication.username; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hot off the presses (in #252). you can now use determineOwner()
const owner = determineOwner(requestOptions);
requestOptions.params = { | ||
...requestOptions.params, | ||
file: requestOptions.data | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a nitpick, but i prefer to mixin user-supplied options after internal props are set.
it feels like a nice contract to explicitly prohibit overwriting what the developer passes in.
requestOptions.params = {
file: requestOptions.data,
...requestOptions.params
};
8e357cb
to
be8628b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just pushed up another commit with:
- a couple naming tweaks
- another test (to get coverage back to 100%)
- two new interfaces for add/update methods to document the responses that will be returned by the server.
i'm scratching my head as to what in the hell is going on with JS Dates on the travis box right now. locally, its all 💚
new Date(2016,7,17).getTime()
> 1471392000000 // ????
edit:
i'm going to be out of the office 'til friday. hopefully this'll give @patrickarlt a chance to look at #251 on its own first. if he's happy with it, we'll merge both and ship.
@jgravois thank you for the review and improvements. Travis date puzzled me; switched to constructing date from milliseconds to see if that will work both with npm test and Travis. |
@jgravois would you please review the last two commits: changing the Date construction because of the Travis problem and adding a test for encode-form-data? |
looks great! i'm going to try to merge/release today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the suggested name change this LGTM, thanks @MikeTschudi!
@@ -30,9 +30,9 @@ export interface IItemIdRequestOptions extends IUserRequestOptions { | |||
owner?: string; | |||
} | |||
|
|||
export interface IItemJsonDataRequestOptions extends IItemIdRequestOptions { | |||
export interface IItemDataOptions extends IItemIdRequestOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest naming this IItemDataRequestOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. i introduced that typo during code review.
i'm going to rebase this branch to clean up the commit history and then merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, just realized i already used IItemDataRequestOptions
in #251.
my best suggestion for this one is IItemDataAddRequestOptions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to be that guy, but I would have gone w/ IItemAddDataRequestOptions
AFFECTS PACKAGES: @esri/arcgis-rest-items
…s of non-objects Fixed addItemData input type and mix-in ordering #254 Switched to using determineOwner call #254 doc response, add another test method and interface rename whoops Changed Date constructor to see if Travis behaves better #254 Added test for FormData path #254 one more interface name change
a79227d
to
39a0710
Compare
🚀 |
For reasonable browsers, a Blob can be converted into a File and sent up with its filename. For IE 11 & Edge, the File constructor is not available, and even if one adds the missing File properties to the Blob, it's sent up to AGOL as "blob" by these two browsers. Changing encode-form-data to use the filename in the FormData.append call gets past this behavior.
I changed the name of IItemJsonDataRequestOptions from a documentation perspective since it can be used by both the JSON and binary functions.
Working on test code.