Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Implement body in Image Source",
"packageName": "react-native-windows",
"email": "54227869+anupriya13@users.noreply.github.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/playground/Samples/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export default class Bootstrap extends React.Component<
: {tintColor: this.state.tintColor},
]}
defaultSource={{uri: this.state.defaultImageUri}}
source={{uri: this.state.imageUri}}
source={{uri: this.state.imageUri, body: 'test'}}
loadingIndicatorSource={{uri: loadingImageUri}}
resizeMode={this.state.selectedResizeMode}
blurRadius={this.state.blurRadius}
Expand Down
7 changes: 7 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ WindowsImageManager::GetImageRandomAccessStreamAsync(
}
}

if (!source.body.empty()) {
auto bodyContent = winrt::Windows::Web::Http::HttpStringContent(
winrt::to_hstring(source.body), winrt::Windows::Storage::Streams::UnicodeEncoding::Utf8, L"application/json");
request.Content(bodyContent);
}

winrt::Windows::Web::Http::HttpResponseMessage response(co_await m_httpClient.SendRequestAsync(request));

if (!response.IsSuccessStatusCode()) {
Expand Down Expand Up @@ -182,6 +188,7 @@ facebook::react::ImageRequest WindowsImageManager::requestImage(
source.height = imageSource.size.height;
source.width = imageSource.size.width;
source.sourceType = ImageSourceType::Download;
source.body = imageSource.body;

auto progressCallback = [weakObserverCoordinator](int64_t loaded, int64_t total) {
if (auto observerCoordinator = weakObserverCoordinator.lock()) {
Expand Down
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/Utils/ImageUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct ReactImageSource {
std::string uri;
std::string method;
std::vector<std::pair<std::string, std::string>> headers;
std::string body;
double width = 0;
double height = 0;
double scale = 1.0;
Expand Down