+1
-1
server/internal/handler/lrcHandlers.go
+1
-1
server/internal/handler/lrcHandlers.go
···
162
162
h.badRequest(w, errors.New("must post an image"))
163
163
return
164
164
}
165
-
blob, err := h.rm.PostImage(cs, file, r.Context())
165
+
blob, err := h.rm.PostImage(cs, file, fheader, r.Context())
166
166
if err != nil {
167
167
h.serverError(w, errors.New("failed to upload: "+err.Error()))
168
168
return
+7
-1
server/internal/oauth/oauthclient.go
+7
-1
server/internal/oauth/oauthclient.go
···
177
177
return profile, nil
178
178
}
179
179
180
-
func UploadBLOB(cs *oauth.ClientSession, file multipart.File, ctx context.Context) (*lexutil.BlobSchema, error) {
180
+
func UploadBLOB(cs *oauth.ClientSession, file multipart.File, fileHeader *multipart.FileHeader, ctx context.Context) (*lexutil.BlobSchema, error) {
181
181
client := cs.APIClient()
182
182
183
183
fileBytes, err := io.ReadAll(file)
···
187
187
fileReader := bytes.NewReader(fileBytes)
188
188
189
189
req := atpclient.NewAPIRequest("POST", "com.atproto.repo.uploadBlob", fileReader)
190
+
contentType := fileHeader.Header.Get("Content-Type")
191
+
if contentType == "" {
192
+
193
+
req.Headers.Add("Content-Type", "application/octet-stream")
194
+
}
195
+
req.Headers.Add("Content-Length", fmt.Sprintf("%d", len(fileBytes)))
190
196
resp, err := client.Do(ctx, req)
191
197
if err != nil {
192
198
return nil, err
+2
-2
server/internal/recordmanager/media.go
+2
-2
server/internal/recordmanager/media.go
···
13
13
"time"
14
14
)
15
15
16
-
func (rm *RecordManager) PostImage(cs *atoauth.ClientSession, file multipart.File, ctx context.Context) (*lexutil.BlobSchema, error) {
17
-
return oauth.UploadBLOB(cs, file, ctx)
16
+
func (rm *RecordManager) PostImage(cs *atoauth.ClientSession, file multipart.File, fileHeader *multipart.FileHeader, ctx context.Context) (*lexutil.BlobSchema, error) {
17
+
return oauth.UploadBLOB(cs, file, fileHeader, ctx)
18
18
}
19
19
20
20
func (rm *RecordManager) PostMedia(cs *atoauth.ClientSession, mr *types.ParseMediaRequest, ctx context.Context) error {