MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / CreateFile

Method CreateFile

pkg/cluster/node.go:188–214  ·  view source on GitHub ↗
(ctx context.Context, args *fs.StatelessCreateFileService)

Source from the content-addressed store, hash-verified

186}
187
188func (b *masterNode) CreateFile(ctx context.Context, args *fs.StatelessCreateFileService) error {
189 reqBody, err := json.Marshal(args)
190 if err != nil {
191 return fmt.Errorf("failed to marshal request body: %w", err)
192 }
193
194 requestDst := routes.MasterStatelessUrl(MasterSiteUrlFromContext(ctx), "create")
195 resp, err := b.client.Request(
196 "POST",
197 requestDst.String(),
198 bytes.NewReader(reqBody),
199 request.WithContext(ctx),
200 request.WithSlaveMeta(NodeIdFromContext(ctx)),
201 request.WithLogger(logging.FromContext(ctx)),
202 ).CheckHTTPResponse(200).DecodeResponse()
203 if err != nil {
204 return err
205 }
206
207 // 处理列取结果
208 if resp.Code != 0 {
209 return serializer.NewErrorFromResponse(resp)
210 }
211
212 return nil
213
214}
215
216func (b *masterNode) CreateDownloader(ctx context.Context, c request.Client, settings setting.Provider) (downloader.Downloader, error) {
217 return NewDownloader(ctx, c, settings, b.Settings(ctx))

Callers

nothing calls this directly

Calls 12

MasterStatelessUrlFunction · 0.92
WithContextFunction · 0.92
WithSlaveMetaFunction · 0.92
WithLoggerFunction · 0.92
FromContextFunction · 0.92
NewErrorFromResponseFunction · 0.92
MasterSiteUrlFromContextFunction · 0.85
NodeIdFromContextFunction · 0.85
DecodeResponseMethod · 0.80
CheckHTTPResponseMethod · 0.80
RequestMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected